@cyguin/changelog-core 0.1.6
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/dist/index.cjs +26 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +51 -0
- package/dist/index.d.ts +51 -0
- package/dist/index.js +24 -0
- package/dist/index.js.map +1 -0
- package/package.json +26 -0
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// src/cuid2.ts
|
|
4
|
+
var CUID_ALPHABET = "0123456789abcdefghijklmnopqrstuvwxyz";
|
|
5
|
+
var CUID_PREFIX = "c";
|
|
6
|
+
function randomBytes(count) {
|
|
7
|
+
const bytes = [];
|
|
8
|
+
for (let i = 0; i < count; i++) {
|
|
9
|
+
bytes.push(Math.floor(Math.random() * CUID_ALPHABET.length));
|
|
10
|
+
}
|
|
11
|
+
return bytes;
|
|
12
|
+
}
|
|
13
|
+
function encodeAlphabet(bytes, alphabet) {
|
|
14
|
+
return bytes.map((b) => alphabet[b % alphabet.length]).join("");
|
|
15
|
+
}
|
|
16
|
+
function generateCuid2() {
|
|
17
|
+
const timestamp = Date.now().toString(36).toLowerCase();
|
|
18
|
+
const random1 = encodeAlphabet(randomBytes(13), CUID_ALPHABET);
|
|
19
|
+
const random2 = encodeAlphabet(randomBytes(13), CUID_ALPHABET);
|
|
20
|
+
const counter = (Math.random() * 1e3 | 0).toString(36).toLowerCase();
|
|
21
|
+
return `${CUID_PREFIX}${timestamp}${random1}${random2}${counter}`;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
exports.generateCuid2 = generateCuid2;
|
|
25
|
+
//# sourceMappingURL=index.cjs.map
|
|
26
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/cuid2.ts"],"names":[],"mappings":";;;AAAA,IAAM,aAAA,GAAgB,sCAAA;AACtB,IAAM,WAAA,GAAc,GAAA;AAEpB,SAAS,YAAY,KAAA,EAAyB;AAC5C,EAAA,MAAM,QAAkB,EAAC;AACzB,EAAA,KAAA,IAAS,CAAA,GAAI,CAAA,EAAG,CAAA,GAAI,KAAA,EAAO,CAAA,EAAA,EAAK;AAC9B,IAAA,KAAA,CAAM,IAAA,CAAK,KAAK,KAAA,CAAM,IAAA,CAAK,QAAO,GAAI,aAAA,CAAc,MAAM,CAAC,CAAA;AAAA,EAC7D;AACA,EAAA,OAAO,KAAA;AACT;AAEA,SAAS,cAAA,CAAe,OAAiB,QAAA,EAA0B;AACjE,EAAA,OAAO,KAAA,CAAM,GAAA,CAAI,CAAA,CAAA,KAAK,QAAA,CAAS,CAAA,GAAI,SAAS,MAAM,CAAC,CAAA,CAAE,IAAA,CAAK,EAAE,CAAA;AAC9D;AAEO,SAAS,aAAA,GAAwB;AACtC,EAAA,MAAM,YAAY,IAAA,CAAK,GAAA,GAAM,QAAA,CAAS,EAAE,EAAE,WAAA,EAAY;AACtD,EAAA,MAAM,OAAA,GAAU,cAAA,CAAe,WAAA,CAAY,EAAE,GAAG,aAAa,CAAA;AAC7D,EAAA,MAAM,OAAA,GAAU,cAAA,CAAe,WAAA,CAAY,EAAE,GAAG,aAAa,CAAA;AAC7D,EAAA,MAAM,OAAA,GAAA,CAAW,KAAK,MAAA,EAAO,GAAI,MAAO,CAAA,EAAG,QAAA,CAAS,EAAE,CAAA,CAAE,WAAA,EAAY;AACpE,EAAA,OAAO,CAAA,EAAG,WAAW,CAAA,EAAG,SAAS,GAAG,OAAO,CAAA,EAAG,OAAO,CAAA,EAAG,OAAO,CAAA,CAAA;AACjE","file":"index.cjs","sourcesContent":["const CUID_ALPHABET = '0123456789abcdefghijklmnopqrstuvwxyz'\nconst CUID_PREFIX = 'c'\n\nfunction randomBytes(count: number): number[] {\n const bytes: number[] = []\n for (let i = 0; i < count; i++) {\n bytes.push(Math.floor(Math.random() * CUID_ALPHABET.length))\n }\n return bytes\n}\n\nfunction encodeAlphabet(bytes: number[], alphabet: string): string {\n return bytes.map(b => alphabet[b % alphabet.length]).join('')\n}\n\nexport function generateCuid2(): string {\n const timestamp = Date.now().toString(36).toLowerCase()\n const random1 = encodeAlphabet(randomBytes(13), CUID_ALPHABET)\n const random2 = encodeAlphabet(randomBytes(13), CUID_ALPHABET)\n const counter = (Math.random() * 1000 | 0).toString(36).toLowerCase()\n return `${CUID_PREFIX}${timestamp}${random1}${random2}${counter}`\n}\n"]}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
interface Entry {
|
|
2
|
+
id: string;
|
|
3
|
+
title: string;
|
|
4
|
+
body: string;
|
|
5
|
+
version: string | null;
|
|
6
|
+
publishedAt: string;
|
|
7
|
+
createdAt: string;
|
|
8
|
+
updatedAt: string;
|
|
9
|
+
isPublished: boolean;
|
|
10
|
+
tags: string[];
|
|
11
|
+
}
|
|
12
|
+
interface ReadRecord {
|
|
13
|
+
entryId: string;
|
|
14
|
+
userId: string;
|
|
15
|
+
readAt: string;
|
|
16
|
+
}
|
|
17
|
+
interface CreateEntryInput {
|
|
18
|
+
title: string;
|
|
19
|
+
body: string;
|
|
20
|
+
version?: string;
|
|
21
|
+
publishedAt?: string;
|
|
22
|
+
isPublished?: boolean;
|
|
23
|
+
tags?: string[];
|
|
24
|
+
}
|
|
25
|
+
interface UpdateEntryInput {
|
|
26
|
+
title?: string;
|
|
27
|
+
body?: string;
|
|
28
|
+
version?: string | null;
|
|
29
|
+
publishedAt?: string;
|
|
30
|
+
isPublished?: boolean;
|
|
31
|
+
tags?: string[];
|
|
32
|
+
}
|
|
33
|
+
interface GetEntriesOptions {
|
|
34
|
+
limit?: number;
|
|
35
|
+
offset?: number;
|
|
36
|
+
publishedOnly?: boolean;
|
|
37
|
+
}
|
|
38
|
+
interface ChangelogAdapter {
|
|
39
|
+
getEntries(opts?: GetEntriesOptions): Promise<Entry[]>;
|
|
40
|
+
getEntry(id: string): Promise<Entry | null>;
|
|
41
|
+
createEntry(data: CreateEntryInput): Promise<Entry>;
|
|
42
|
+
updateEntry(id: string, data: UpdateEntryInput): Promise<Entry>;
|
|
43
|
+
deleteEntry(id: string): Promise<void>;
|
|
44
|
+
markRead(entryId: string, userId: string): Promise<void>;
|
|
45
|
+
getUnreadCount(userId: string): Promise<number>;
|
|
46
|
+
runMigrations(): Promise<void>;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
declare function generateCuid2(): string;
|
|
50
|
+
|
|
51
|
+
export { type ChangelogAdapter, type CreateEntryInput, type Entry, type GetEntriesOptions, type ReadRecord, type UpdateEntryInput, generateCuid2 };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
interface Entry {
|
|
2
|
+
id: string;
|
|
3
|
+
title: string;
|
|
4
|
+
body: string;
|
|
5
|
+
version: string | null;
|
|
6
|
+
publishedAt: string;
|
|
7
|
+
createdAt: string;
|
|
8
|
+
updatedAt: string;
|
|
9
|
+
isPublished: boolean;
|
|
10
|
+
tags: string[];
|
|
11
|
+
}
|
|
12
|
+
interface ReadRecord {
|
|
13
|
+
entryId: string;
|
|
14
|
+
userId: string;
|
|
15
|
+
readAt: string;
|
|
16
|
+
}
|
|
17
|
+
interface CreateEntryInput {
|
|
18
|
+
title: string;
|
|
19
|
+
body: string;
|
|
20
|
+
version?: string;
|
|
21
|
+
publishedAt?: string;
|
|
22
|
+
isPublished?: boolean;
|
|
23
|
+
tags?: string[];
|
|
24
|
+
}
|
|
25
|
+
interface UpdateEntryInput {
|
|
26
|
+
title?: string;
|
|
27
|
+
body?: string;
|
|
28
|
+
version?: string | null;
|
|
29
|
+
publishedAt?: string;
|
|
30
|
+
isPublished?: boolean;
|
|
31
|
+
tags?: string[];
|
|
32
|
+
}
|
|
33
|
+
interface GetEntriesOptions {
|
|
34
|
+
limit?: number;
|
|
35
|
+
offset?: number;
|
|
36
|
+
publishedOnly?: boolean;
|
|
37
|
+
}
|
|
38
|
+
interface ChangelogAdapter {
|
|
39
|
+
getEntries(opts?: GetEntriesOptions): Promise<Entry[]>;
|
|
40
|
+
getEntry(id: string): Promise<Entry | null>;
|
|
41
|
+
createEntry(data: CreateEntryInput): Promise<Entry>;
|
|
42
|
+
updateEntry(id: string, data: UpdateEntryInput): Promise<Entry>;
|
|
43
|
+
deleteEntry(id: string): Promise<void>;
|
|
44
|
+
markRead(entryId: string, userId: string): Promise<void>;
|
|
45
|
+
getUnreadCount(userId: string): Promise<number>;
|
|
46
|
+
runMigrations(): Promise<void>;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
declare function generateCuid2(): string;
|
|
50
|
+
|
|
51
|
+
export { type ChangelogAdapter, type CreateEntryInput, type Entry, type GetEntriesOptions, type ReadRecord, type UpdateEntryInput, generateCuid2 };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// src/cuid2.ts
|
|
2
|
+
var CUID_ALPHABET = "0123456789abcdefghijklmnopqrstuvwxyz";
|
|
3
|
+
var CUID_PREFIX = "c";
|
|
4
|
+
function randomBytes(count) {
|
|
5
|
+
const bytes = [];
|
|
6
|
+
for (let i = 0; i < count; i++) {
|
|
7
|
+
bytes.push(Math.floor(Math.random() * CUID_ALPHABET.length));
|
|
8
|
+
}
|
|
9
|
+
return bytes;
|
|
10
|
+
}
|
|
11
|
+
function encodeAlphabet(bytes, alphabet) {
|
|
12
|
+
return bytes.map((b) => alphabet[b % alphabet.length]).join("");
|
|
13
|
+
}
|
|
14
|
+
function generateCuid2() {
|
|
15
|
+
const timestamp = Date.now().toString(36).toLowerCase();
|
|
16
|
+
const random1 = encodeAlphabet(randomBytes(13), CUID_ALPHABET);
|
|
17
|
+
const random2 = encodeAlphabet(randomBytes(13), CUID_ALPHABET);
|
|
18
|
+
const counter = (Math.random() * 1e3 | 0).toString(36).toLowerCase();
|
|
19
|
+
return `${CUID_PREFIX}${timestamp}${random1}${random2}${counter}`;
|
|
20
|
+
}
|
|
21
|
+
|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","file":"index.js","sourcesContent":["const CUID_ALPHABET = '0123456789abcdefghijklmnopqrstuvwxyz'\nconst CUID_PREFIX = 'c'\n\nfunction randomBytes(count: number): number[] {\n const bytes: number[] = []\n for (let i = 0; i < count; i++) {\n bytes.push(Math.floor(Math.random() * CUID_ALPHABET.length))\n }\n return bytes\n}\n\nfunction encodeAlphabet(bytes: number[], alphabet: string): string {\n return bytes.map(b => alphabet[b % alphabet.length]).join('')\n}\n\nexport function generateCuid2(): string {\n const timestamp = Date.now().toString(36).toLowerCase()\n const random1 = encodeAlphabet(randomBytes(13), CUID_ALPHABET)\n const random2 = encodeAlphabet(randomBytes(13), CUID_ALPHABET)\n const counter = (Math.random() * 1000 | 0).toString(36).toLowerCase()\n return `${CUID_PREFIX}${timestamp}${random1}${random2}${counter}`\n}\n"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@cyguin/changelog-core",
|
|
3
|
+
"version": "0.1.6",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "TypeScript types and ChangelogAdapter interface for @cyguin/changelog",
|
|
6
|
+
"keywords": ["changelog", "changelog-feed", "nextjs", "typescript"],
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"author": "Cyguin <dev@cyguin.com>",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "https://github.com/cyguin/changelog"
|
|
12
|
+
},
|
|
13
|
+
"homepage": "https://github.com/cyguin/changelog#readme",
|
|
14
|
+
"main": "./dist/index.js",
|
|
15
|
+
"module": "./dist/index.js",
|
|
16
|
+
"types": "./dist/index.d.ts",
|
|
17
|
+
"exports": {
|
|
18
|
+
".": "./dist/index.js"
|
|
19
|
+
},
|
|
20
|
+
"files": ["dist"],
|
|
21
|
+
"scripts": {
|
|
22
|
+
"build": "tsup",
|
|
23
|
+
"test": "vitest run",
|
|
24
|
+
"typecheck": "tsc --noEmit"
|
|
25
|
+
}
|
|
26
|
+
}
|