@oblax/bookmarks 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.
@@ -0,0 +1,38 @@
1
+ import type { OblaxContext } from '@oblax/core';
2
+ import type { Bookmark, BookmarksConfig, CreateBookmarkParams, DeleteBookmarkParams, ListBookmarksParams, ListMyBookmarksParams } from './types.js';
3
+ /**
4
+ * The Bookmarks module.
5
+ *
6
+ * Manages bookmarks for the authenticated user or any user (when permitted).
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * const oblax = new Oblax({
11
+ * endpoint: 'https://api.my-app.oblax.io',
12
+ * clientId: 'my-web-app',
13
+ * modules: [PlatformServer(), Bookmarks()],
14
+ * })
15
+ *
16
+ * const bookmark = await oblax.bookmarks.create({
17
+ * type: 'article',
18
+ * userId: 'user-id',
19
+ * recordId: 'article-id',
20
+ * title: 'My favourite article',
21
+ * })
22
+ *
23
+ * const mine = await oblax.bookmarks.listMy({ type: 'article' })
24
+ * ```
25
+ */
26
+ export declare class BookmarksModule {
27
+ private readonly ctx;
28
+ constructor(ctx: OblaxContext, _config: BookmarksConfig);
29
+ /** Lists bookmarks of a given type for the currently authenticated user. */
30
+ listMy(params: ListMyBookmarksParams): Promise<Bookmark[]>;
31
+ /** Lists bookmarks of a given type for a specific user. */
32
+ list(params: ListBookmarksParams): Promise<Bookmark[]>;
33
+ /** Creates a new bookmark. */
34
+ create(params: CreateBookmarkParams): Promise<Bookmark>;
35
+ /** Deletes a bookmark by ID. Returns `void` (HTTP 204). */
36
+ delete(params: DeleteBookmarkParams): Promise<void>;
37
+ }
38
+ //# sourceMappingURL=bookmarks-module.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bookmarks-module.d.ts","sourceRoot":"","sources":["../src/bookmarks-module.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC/C,OAAO,KAAK,EACV,QAAQ,EACR,eAAe,EACf,oBAAoB,EACpB,oBAAoB,EACpB,mBAAmB,EACnB,qBAAqB,EACtB,MAAM,YAAY,CAAA;AAYnB;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,qBAAa,eAAe;IACd,OAAO,CAAC,QAAQ,CAAC,GAAG;gBAAH,GAAG,EAAE,YAAY,EAAE,OAAO,EAAE,eAAe;IAExE,4EAA4E;IACtE,MAAM,CAAC,MAAM,EAAE,qBAAqB,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;IAIhE,2DAA2D;IACrD,IAAI,CAAC,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;IAI5D,8BAA8B;IACxB,MAAM,CAAC,MAAM,EAAE,oBAAoB,GAAG,OAAO,CAAC,QAAQ,CAAC;IAO7D,2DAA2D;IACrD,MAAM,CAAC,MAAM,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC;CAK1D"}
@@ -0,0 +1,54 @@
1
+ /** Maps camelCase input to the snake_case wire format. */
2
+ function bookmarkToApi(params) {
3
+ return {
4
+ type: params.type,
5
+ record_id: params.recordId,
6
+ user_id: params.userId,
7
+ title: params.title,
8
+ };
9
+ }
10
+ /**
11
+ * The Bookmarks module.
12
+ *
13
+ * Manages bookmarks for the authenticated user or any user (when permitted).
14
+ *
15
+ * @example
16
+ * ```typescript
17
+ * const oblax = new Oblax({
18
+ * endpoint: 'https://api.my-app.oblax.io',
19
+ * clientId: 'my-web-app',
20
+ * modules: [PlatformServer(), Bookmarks()],
21
+ * })
22
+ *
23
+ * const bookmark = await oblax.bookmarks.create({
24
+ * type: 'article',
25
+ * userId: 'user-id',
26
+ * recordId: 'article-id',
27
+ * title: 'My favourite article',
28
+ * })
29
+ *
30
+ * const mine = await oblax.bookmarks.listMy({ type: 'article' })
31
+ * ```
32
+ */
33
+ export class BookmarksModule {
34
+ constructor(ctx, _config) {
35
+ this.ctx = ctx;
36
+ }
37
+ /** Lists bookmarks of a given type for the currently authenticated user. */
38
+ async listMy(params) {
39
+ return this.ctx.http.get(`/bookmarks/me/type/${params.type}`);
40
+ }
41
+ /** Lists bookmarks of a given type for a specific user. */
42
+ async list(params) {
43
+ return this.ctx.http.get(`/bookmarks/${params.userId}/type/${params.type}`);
44
+ }
45
+ /** Creates a new bookmark. */
46
+ async create(params) {
47
+ return this.ctx.http.post(`/bookmarks/${params.userId}/type/${params.type}`, bookmarkToApi(params));
48
+ }
49
+ /** Deletes a bookmark by ID. Returns `void` (HTTP 204). */
50
+ async delete(params) {
51
+ return this.ctx.http.delete(`/bookmarks/${params.userId}/type/${params.type}/${params.id}`);
52
+ }
53
+ }
54
+ //# sourceMappingURL=bookmarks-module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bookmarks-module.js","sourceRoot":"","sources":["../src/bookmarks-module.ts"],"names":[],"mappings":"AAUA,0DAA0D;AAC1D,SAAS,aAAa,CAAC,MAA4B;IACjD,OAAO;QACL,IAAI,EAAO,MAAM,CAAC,IAAI;QACtB,SAAS,EAAE,MAAM,CAAC,QAAQ;QAC1B,OAAO,EAAI,MAAM,CAAC,MAAM;QACxB,KAAK,EAAM,MAAM,CAAC,KAAK;KACxB,CAAA;AACH,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,OAAO,eAAe;IAC1B,YAA6B,GAAiB,EAAE,OAAwB;QAA3C,QAAG,GAAH,GAAG,CAAc;IAA6B,CAAC;IAE5E,4EAA4E;IAC5E,KAAK,CAAC,MAAM,CAAC,MAA6B;QACxC,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAa,sBAAsB,MAAM,CAAC,IAAI,EAAE,CAAC,CAAA;IAC3E,CAAC;IAED,2DAA2D;IAC3D,KAAK,CAAC,IAAI,CAAC,MAA2B;QACpC,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAa,cAAc,MAAM,CAAC,MAAM,SAAS,MAAM,CAAC,IAAI,EAAE,CAAC,CAAA;IACzF,CAAC;IAED,8BAA8B;IAC9B,KAAK,CAAC,MAAM,CAAC,MAA4B;QACvC,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CACvB,cAAc,MAAM,CAAC,MAAM,SAAS,MAAM,CAAC,IAAI,EAAE,EACjD,aAAa,CAAC,MAAM,CAAC,CACtB,CAAA;IACH,CAAC;IAED,2DAA2D;IAC3D,KAAK,CAAC,MAAM,CAAC,MAA4B;QACvC,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CACzB,cAAc,MAAM,CAAC,MAAM,SAAS,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC,EAAE,EAAE,CAC/D,CAAA;IACH,CAAC;CACF"}
@@ -0,0 +1,32 @@
1
+ import type { OblaxModulePlugin } from '@oblax/core';
2
+ import { BookmarksModule } from './bookmarks-module.js';
3
+ import type { BookmarksConfig } from './types.js';
4
+ export { BookmarksModule } from './bookmarks-module.js';
5
+ export type { BookmarksConfig, Bookmark, CreateBookmarkParams, ListBookmarksParams, ListMyBookmarksParams, DeleteBookmarkParams, } from './types.js';
6
+ /**
7
+ * Bookmarks module factory.
8
+ *
9
+ * Registers the bookmarks module with the Oblax SDK. Bookmarks operations are
10
+ * available directly on `oblax.bookmarks`.
11
+ *
12
+ * @example
13
+ * ```typescript
14
+ * import { Oblax } from '@oblax/core'
15
+ * import { PlatformServer } from '@oblax/platform-server'
16
+ * import { Bookmarks } from '@oblax/bookmarks'
17
+ *
18
+ * const oblax = new Oblax({
19
+ * endpoint: 'https://api.my-app.oblax.io',
20
+ * clientId: 'my-web-app',
21
+ * modules: [PlatformServer(), Bookmarks()],
22
+ * })
23
+ *
24
+ * const bookmark = await oblax.bookmarks.create({
25
+ * type: 'article',
26
+ * userId: 'user-id',
27
+ * recordId: 'article-id',
28
+ * })
29
+ * ```
30
+ */
31
+ export declare function Bookmarks(config?: BookmarksConfig): OblaxModulePlugin<'bookmarks', BookmarksModule>;
32
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAgB,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AACvD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAEjD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAEvD,YAAY,EACV,eAAe,EACf,QAAQ,EACR,oBAAoB,EACpB,mBAAmB,EACnB,qBAAqB,EACrB,oBAAoB,GACrB,MAAM,YAAY,CAAA;AAEnB;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,SAAS,CAAC,MAAM,GAAE,eAAoB,GAAG,iBAAiB,CAAC,WAAW,EAAE,eAAe,CAAC,CAOvG"}
package/dist/index.js ADDED
@@ -0,0 +1,36 @@
1
+ import { BookmarksModule } from './bookmarks-module.js';
2
+ export { BookmarksModule } from './bookmarks-module.js';
3
+ /**
4
+ * Bookmarks module factory.
5
+ *
6
+ * Registers the bookmarks module with the Oblax SDK. Bookmarks operations are
7
+ * available directly on `oblax.bookmarks`.
8
+ *
9
+ * @example
10
+ * ```typescript
11
+ * import { Oblax } from '@oblax/core'
12
+ * import { PlatformServer } from '@oblax/platform-server'
13
+ * import { Bookmarks } from '@oblax/bookmarks'
14
+ *
15
+ * const oblax = new Oblax({
16
+ * endpoint: 'https://api.my-app.oblax.io',
17
+ * clientId: 'my-web-app',
18
+ * modules: [PlatformServer(), Bookmarks()],
19
+ * })
20
+ *
21
+ * const bookmark = await oblax.bookmarks.create({
22
+ * type: 'article',
23
+ * userId: 'user-id',
24
+ * recordId: 'article-id',
25
+ * })
26
+ * ```
27
+ */
28
+ export function Bookmarks(config = {}) {
29
+ return {
30
+ name: 'bookmarks',
31
+ create(ctx) {
32
+ return new BookmarksModule(ctx, config);
33
+ },
34
+ };
35
+ }
36
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAGvD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAWvD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,UAAU,SAAS,CAAC,SAA0B,EAAE;IACpD,OAAO;QACL,IAAI,EAAE,WAAW;QACjB,MAAM,CAAC,GAAiB;YACtB,OAAO,IAAI,eAAe,CAAC,GAAG,EAAE,MAAM,CAAC,CAAA;QACzC,CAAC;KACF,CAAA;AACH,CAAC"}
@@ -0,0 +1,39 @@
1
+ /**
2
+ * A bookmark links a user to a record of a given type.
3
+ *
4
+ * The backend model expects `type`, `record_id` and `user_id`;
5
+ * `title` is optional.
6
+ */
7
+ export interface Bookmark {
8
+ id: string;
9
+ type: string;
10
+ record_id: string;
11
+ user_id: string;
12
+ title: string;
13
+ }
14
+ export interface CreateBookmarkParams {
15
+ /** Bookmark category, also sent as the `:type` route parameter. */
16
+ type: string;
17
+ /** User identifier, also sent as the `:uid` route parameter. */
18
+ userId: string;
19
+ /** Target record identifier (required). */
20
+ recordId: string;
21
+ /** Optional display title. */
22
+ title?: string;
23
+ }
24
+ export interface ListBookmarksParams {
25
+ type: string;
26
+ userId: string;
27
+ }
28
+ export interface ListMyBookmarksParams {
29
+ type: string;
30
+ }
31
+ export interface DeleteBookmarkParams {
32
+ type: string;
33
+ userId: string;
34
+ id: string;
35
+ }
36
+ /** Bookmarks module configuration. Reserved for future options. */
37
+ export interface BookmarksConfig {
38
+ }
39
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,EAAE,MAAM,CAAA;IACjB,OAAO,EAAE,MAAM,CAAA;IACf,KAAK,EAAE,MAAM,CAAA;CACd;AAED,MAAM,WAAW,oBAAoB;IACnC,mEAAmE;IACnE,IAAI,EAAE,MAAM,CAAA;IACZ,gEAAgE;IAChE,MAAM,EAAE,MAAM,CAAA;IACd,2CAA2C;IAC3C,QAAQ,EAAE,MAAM,CAAA;IAChB,8BAA8B;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,CAAA;CACf;AAED,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM,CAAA;CACb;AAED,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,CAAA;IACd,EAAE,EAAE,MAAM,CAAA;CACX;AAED,mEAAmE;AACnE,MAAM,WAAW,eAAe;CAE/B"}
package/dist/types.js ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
package/package.json ADDED
@@ -0,0 +1,51 @@
1
+ {
2
+ "name": "@oblax/bookmarks",
3
+ "version": "1.0.0",
4
+ "description": "Oblax SDK — bookmarks module",
5
+ "license": "MIT",
6
+ "author": {
7
+ "name": "Oblax SDK for JavaScript Team",
8
+ "url": "https://docs.oblax.io/docs/getting-started/your-first-sdk-call"
9
+ },
10
+ "homepage": "https://github.com/oblaxio/oblax-sdk-js#readme",
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "git+https://github.com/oblaxio/oblax-sdk-js.git",
14
+ "directory": "packages/bookmarks"
15
+ },
16
+ "bugs": {
17
+ "url": "https://github.com/oblaxio/oblax-sdk-js/issues"
18
+ },
19
+ "keywords": [
20
+ "oblax",
21
+ "sdk",
22
+ "bookmarks"
23
+ ],
24
+ "type": "module",
25
+ "main": "./dist/index.js",
26
+ "types": "./dist/index.d.ts",
27
+ "exports": {
28
+ ".": {
29
+ "import": "./dist/index.js",
30
+ "types": "./dist/index.d.ts"
31
+ }
32
+ },
33
+ "files": [
34
+ "dist"
35
+ ],
36
+ "publishConfig": {
37
+ "access": "public"
38
+ },
39
+ "peerDependencies": {
40
+ "@oblax/core": "1.0.0"
41
+ },
42
+ "devDependencies": {
43
+ "typescript": "^5.5.0",
44
+ "@oblax/core": "1.0.0"
45
+ },
46
+ "scripts": {
47
+ "build": "tsc --build tsconfig.json",
48
+ "typecheck": "tsc --build tsconfig.json --dry",
49
+ "clean": "rm -rf dist tsconfig.tsbuildinfo"
50
+ }
51
+ }