@changelogai/core 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/README.md +7 -0
- package/dist/index.cjs +82 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +21 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.js +52 -0
- package/dist/index.js.map +1 -0
- package/package.json +29 -0
package/README.md
ADDED
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
ChangelogAIError: () => ChangelogAIError,
|
|
24
|
+
InvalidApiKeyError: () => InvalidApiKeyError,
|
|
25
|
+
MissingApiKeyError: () => MissingApiKeyError,
|
|
26
|
+
fetchChangelogs: () => fetchChangelogs
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(index_exports);
|
|
29
|
+
|
|
30
|
+
// src/errors.ts
|
|
31
|
+
var ChangelogAIError = class extends Error {
|
|
32
|
+
constructor(message) {
|
|
33
|
+
super(message);
|
|
34
|
+
this.name = "ChangelogAIError";
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
var MissingApiKeyError = class extends ChangelogAIError {
|
|
38
|
+
constructor() {
|
|
39
|
+
super(
|
|
40
|
+
"Missing ChangelogAI API key. Provide it as an argument or set CHANGELOG_AI_API_SECRET."
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
var InvalidApiKeyError = class extends ChangelogAIError {
|
|
45
|
+
constructor() {
|
|
46
|
+
super("Invalid ChangelogAI API key.");
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
// src/fetchChangelogs.ts
|
|
51
|
+
function resolveApiKey(explicitKey) {
|
|
52
|
+
if (explicitKey) return explicitKey;
|
|
53
|
+
if (typeof process !== "undefined" && typeof process.env !== "undefined" && process.env.CHANGELOG_AI_API_SECRET) {
|
|
54
|
+
return process.env.CHANGELOG_AI_API_SECRET;
|
|
55
|
+
}
|
|
56
|
+
throw new MissingApiKeyError();
|
|
57
|
+
}
|
|
58
|
+
async function fetchChangelogs(apiKey) {
|
|
59
|
+
const resolvedKey = resolveApiKey(apiKey);
|
|
60
|
+
const res = await fetch("https://kk2znfp4-3000.uks1.devtunnels.ms/api/changelogs", {
|
|
61
|
+
method: "POST",
|
|
62
|
+
headers: {
|
|
63
|
+
"Content-Type": "application/json"
|
|
64
|
+
},
|
|
65
|
+
body: JSON.stringify({ apiKey: resolvedKey })
|
|
66
|
+
});
|
|
67
|
+
if (res.status === 401) {
|
|
68
|
+
throw new InvalidApiKeyError();
|
|
69
|
+
}
|
|
70
|
+
if (!res.ok) {
|
|
71
|
+
throw new Error("Failed to fetch changelogs");
|
|
72
|
+
}
|
|
73
|
+
return res.json();
|
|
74
|
+
}
|
|
75
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
76
|
+
0 && (module.exports = {
|
|
77
|
+
ChangelogAIError,
|
|
78
|
+
InvalidApiKeyError,
|
|
79
|
+
MissingApiKeyError,
|
|
80
|
+
fetchChangelogs
|
|
81
|
+
});
|
|
82
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/errors.ts","../src/fetchChangelogs.ts"],"sourcesContent":["export * from \"./fetchChangelogs\";\nexport * from \"./types\";\nexport * from \"./errors\";\n","export class ChangelogAIError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"ChangelogAIError\";\n }\n}\n\nexport class MissingApiKeyError extends ChangelogAIError {\n constructor() {\n super(\n \"Missing ChangelogAI API key. Provide it as an argument or set CHANGELOG_AI_API_SECRET.\"\n );\n }\n}\n\nexport class InvalidApiKeyError extends ChangelogAIError {\n constructor() {\n super(\"Invalid ChangelogAI API key.\");\n }\n}\n","import {\n InvalidApiKeyError,\n MissingApiKeyError,\n} from \"./errors\";\nimport type { FetchChangelogsResponse } from \"./types\";\n\nfunction resolveApiKey(explicitKey?: string): string {\n if (explicitKey) return explicitKey;\n\n if (\n typeof process !== \"undefined\" &&\n typeof process.env !== \"undefined\" &&\n process.env.CHANGELOG_AI_API_SECRET\n ) {\n return process.env.CHANGELOG_AI_API_SECRET;\n }\n\n throw new MissingApiKeyError();\n}\n\nexport async function fetchChangelogs(\n apiKey?: string\n): Promise<FetchChangelogsResponse> {\n const resolvedKey = resolveApiKey(apiKey);\n\n const res = await fetch(\"https://kk2znfp4-3000.uks1.devtunnels.ms/api/changelogs\", {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify({ apiKey: resolvedKey }),\n });\n\n if (res.status === 401) {\n throw new InvalidApiKeyError();\n }\n\n if (!res.ok) {\n throw new Error(\"Failed to fetch changelogs\");\n }\n\n return res.json();\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAO,IAAM,mBAAN,cAA+B,MAAM;AAAA,EAC1C,YAAY,SAAiB;AAC3B,UAAM,OAAO;AACb,SAAK,OAAO;AAAA,EACd;AACF;AAEO,IAAM,qBAAN,cAAiC,iBAAiB;AAAA,EACvD,cAAc;AACZ;AAAA,MACE;AAAA,IACF;AAAA,EACF;AACF;AAEO,IAAM,qBAAN,cAAiC,iBAAiB;AAAA,EACvD,cAAc;AACZ,UAAM,8BAA8B;AAAA,EACtC;AACF;;;ACbA,SAAS,cAAc,aAA8B;AACnD,MAAI,YAAa,QAAO;AAExB,MACE,OAAO,YAAY,eACnB,OAAO,QAAQ,QAAQ,eACvB,QAAQ,IAAI,yBACZ;AACA,WAAO,QAAQ,IAAI;AAAA,EACrB;AAEA,QAAM,IAAI,mBAAmB;AAC/B;AAEA,eAAsB,gBACpB,QACkC;AAClC,QAAM,cAAc,cAAc,MAAM;AAExC,QAAM,MAAM,MAAM,MAAM,2DAA2D;AAAA,IACjF,QAAQ;AAAA,IACR,SAAS;AAAA,MACP,gBAAgB;AAAA,IAClB;AAAA,IACA,MAAM,KAAK,UAAU,EAAE,QAAQ,YAAY,CAAC;AAAA,EAC9C,CAAC;AAED,MAAI,IAAI,WAAW,KAAK;AACtB,UAAM,IAAI,mBAAmB;AAAA,EAC/B;AAEA,MAAI,CAAC,IAAI,IAAI;AACX,UAAM,IAAI,MAAM,4BAA4B;AAAA,EAC9C;AAEA,SAAO,IAAI,KAAK;AAClB;","names":[]}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
type Changelog = {
|
|
2
|
+
id: string;
|
|
3
|
+
title: string;
|
|
4
|
+
content: string;
|
|
5
|
+
createdAt: string;
|
|
6
|
+
};
|
|
7
|
+
type FetchChangelogsResponse = Changelog[];
|
|
8
|
+
|
|
9
|
+
declare function fetchChangelogs(apiKey?: string): Promise<FetchChangelogsResponse>;
|
|
10
|
+
|
|
11
|
+
declare class ChangelogAIError extends Error {
|
|
12
|
+
constructor(message: string);
|
|
13
|
+
}
|
|
14
|
+
declare class MissingApiKeyError extends ChangelogAIError {
|
|
15
|
+
constructor();
|
|
16
|
+
}
|
|
17
|
+
declare class InvalidApiKeyError extends ChangelogAIError {
|
|
18
|
+
constructor();
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export { type Changelog, ChangelogAIError, type FetchChangelogsResponse, InvalidApiKeyError, MissingApiKeyError, fetchChangelogs };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
type Changelog = {
|
|
2
|
+
id: string;
|
|
3
|
+
title: string;
|
|
4
|
+
content: string;
|
|
5
|
+
createdAt: string;
|
|
6
|
+
};
|
|
7
|
+
type FetchChangelogsResponse = Changelog[];
|
|
8
|
+
|
|
9
|
+
declare function fetchChangelogs(apiKey?: string): Promise<FetchChangelogsResponse>;
|
|
10
|
+
|
|
11
|
+
declare class ChangelogAIError extends Error {
|
|
12
|
+
constructor(message: string);
|
|
13
|
+
}
|
|
14
|
+
declare class MissingApiKeyError extends ChangelogAIError {
|
|
15
|
+
constructor();
|
|
16
|
+
}
|
|
17
|
+
declare class InvalidApiKeyError extends ChangelogAIError {
|
|
18
|
+
constructor();
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export { type Changelog, ChangelogAIError, type FetchChangelogsResponse, InvalidApiKeyError, MissingApiKeyError, fetchChangelogs };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// src/errors.ts
|
|
2
|
+
var ChangelogAIError = class extends Error {
|
|
3
|
+
constructor(message) {
|
|
4
|
+
super(message);
|
|
5
|
+
this.name = "ChangelogAIError";
|
|
6
|
+
}
|
|
7
|
+
};
|
|
8
|
+
var MissingApiKeyError = class extends ChangelogAIError {
|
|
9
|
+
constructor() {
|
|
10
|
+
super(
|
|
11
|
+
"Missing ChangelogAI API key. Provide it as an argument or set CHANGELOG_AI_API_SECRET."
|
|
12
|
+
);
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
var InvalidApiKeyError = class extends ChangelogAIError {
|
|
16
|
+
constructor() {
|
|
17
|
+
super("Invalid ChangelogAI API key.");
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
// src/fetchChangelogs.ts
|
|
22
|
+
function resolveApiKey(explicitKey) {
|
|
23
|
+
if (explicitKey) return explicitKey;
|
|
24
|
+
if (typeof process !== "undefined" && typeof process.env !== "undefined" && process.env.CHANGELOG_AI_API_SECRET) {
|
|
25
|
+
return process.env.CHANGELOG_AI_API_SECRET;
|
|
26
|
+
}
|
|
27
|
+
throw new MissingApiKeyError();
|
|
28
|
+
}
|
|
29
|
+
async function fetchChangelogs(apiKey) {
|
|
30
|
+
const resolvedKey = resolveApiKey(apiKey);
|
|
31
|
+
const res = await fetch("https://kk2znfp4-3000.uks1.devtunnels.ms/api/changelogs", {
|
|
32
|
+
method: "POST",
|
|
33
|
+
headers: {
|
|
34
|
+
"Content-Type": "application/json"
|
|
35
|
+
},
|
|
36
|
+
body: JSON.stringify({ apiKey: resolvedKey })
|
|
37
|
+
});
|
|
38
|
+
if (res.status === 401) {
|
|
39
|
+
throw new InvalidApiKeyError();
|
|
40
|
+
}
|
|
41
|
+
if (!res.ok) {
|
|
42
|
+
throw new Error("Failed to fetch changelogs");
|
|
43
|
+
}
|
|
44
|
+
return res.json();
|
|
45
|
+
}
|
|
46
|
+
export {
|
|
47
|
+
ChangelogAIError,
|
|
48
|
+
InvalidApiKeyError,
|
|
49
|
+
MissingApiKeyError,
|
|
50
|
+
fetchChangelogs
|
|
51
|
+
};
|
|
52
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/errors.ts","../src/fetchChangelogs.ts"],"sourcesContent":["export class ChangelogAIError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"ChangelogAIError\";\n }\n}\n\nexport class MissingApiKeyError extends ChangelogAIError {\n constructor() {\n super(\n \"Missing ChangelogAI API key. Provide it as an argument or set CHANGELOG_AI_API_SECRET.\"\n );\n }\n}\n\nexport class InvalidApiKeyError extends ChangelogAIError {\n constructor() {\n super(\"Invalid ChangelogAI API key.\");\n }\n}\n","import {\n InvalidApiKeyError,\n MissingApiKeyError,\n} from \"./errors\";\nimport type { FetchChangelogsResponse } from \"./types\";\n\nfunction resolveApiKey(explicitKey?: string): string {\n if (explicitKey) return explicitKey;\n\n if (\n typeof process !== \"undefined\" &&\n typeof process.env !== \"undefined\" &&\n process.env.CHANGELOG_AI_API_SECRET\n ) {\n return process.env.CHANGELOG_AI_API_SECRET;\n }\n\n throw new MissingApiKeyError();\n}\n\nexport async function fetchChangelogs(\n apiKey?: string\n): Promise<FetchChangelogsResponse> {\n const resolvedKey = resolveApiKey(apiKey);\n\n const res = await fetch(\"https://kk2znfp4-3000.uks1.devtunnels.ms/api/changelogs\", {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify({ apiKey: resolvedKey }),\n });\n\n if (res.status === 401) {\n throw new InvalidApiKeyError();\n }\n\n if (!res.ok) {\n throw new Error(\"Failed to fetch changelogs\");\n }\n\n return res.json();\n}\n"],"mappings":";AAAO,IAAM,mBAAN,cAA+B,MAAM;AAAA,EAC1C,YAAY,SAAiB;AAC3B,UAAM,OAAO;AACb,SAAK,OAAO;AAAA,EACd;AACF;AAEO,IAAM,qBAAN,cAAiC,iBAAiB;AAAA,EACvD,cAAc;AACZ;AAAA,MACE;AAAA,IACF;AAAA,EACF;AACF;AAEO,IAAM,qBAAN,cAAiC,iBAAiB;AAAA,EACvD,cAAc;AACZ,UAAM,8BAA8B;AAAA,EACtC;AACF;;;ACbA,SAAS,cAAc,aAA8B;AACnD,MAAI,YAAa,QAAO;AAExB,MACE,OAAO,YAAY,eACnB,OAAO,QAAQ,QAAQ,eACvB,QAAQ,IAAI,yBACZ;AACA,WAAO,QAAQ,IAAI;AAAA,EACrB;AAEA,QAAM,IAAI,mBAAmB;AAC/B;AAEA,eAAsB,gBACpB,QACkC;AAClC,QAAM,cAAc,cAAc,MAAM;AAExC,QAAM,MAAM,MAAM,MAAM,2DAA2D;AAAA,IACjF,QAAQ;AAAA,IACR,SAAS;AAAA,MACP,gBAAgB;AAAA,IAClB;AAAA,IACA,MAAM,KAAK,UAAU,EAAE,QAAQ,YAAY,CAAC;AAAA,EAC9C,CAAC;AAED,MAAI,IAAI,WAAW,KAAK;AACtB,UAAM,IAAI,mBAAmB;AAAA,EAC/B;AAEA,MAAI,CAAC,IAAI,IAAI;AACX,UAAM,IAAI,MAAM,4BAA4B;AAAA,EAC9C;AAEA,SAAO,IAAI,KAAK;AAClB;","names":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@changelogai/core",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Framework-agnostic core SDK for ChangelogAI",
|
|
5
|
+
|
|
6
|
+
"type": "module",
|
|
7
|
+
|
|
8
|
+
"main": "dist/index.js",
|
|
9
|
+
"module": "dist/index.js",
|
|
10
|
+
"types": "dist/index.d.ts",
|
|
11
|
+
|
|
12
|
+
"files": ["dist"],
|
|
13
|
+
|
|
14
|
+
"engines": {
|
|
15
|
+
"node": ">=18"
|
|
16
|
+
},
|
|
17
|
+
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "tsup"
|
|
20
|
+
},
|
|
21
|
+
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"@types/node": "^25.0.3",
|
|
24
|
+
"tsup": "^8.5.1",
|
|
25
|
+
"tsx": "^4.21.0",
|
|
26
|
+
"typescript": "^5.9.3",
|
|
27
|
+
"dotenv": "^17.2.3"
|
|
28
|
+
}
|
|
29
|
+
}
|