@plucky-ai/node 0.2.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 ADDED
@@ -0,0 +1,123 @@
1
+ # @plucky-ai/node
2
+
3
+ Official Node.js SDK for the Plucky API. Use this package to interact with the Plucky API from your server-side applications.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @plucky-ai/node
9
+ # or
10
+ yarn add @plucky-ai/node
11
+ # or
12
+ pnpm add @plucky-ai/node
13
+ ```
14
+
15
+ ## Quick Start
16
+
17
+ ```typescript
18
+ import Plucky from '@plucky-ai/node'
19
+
20
+ const plucky = new Plucky({
21
+ apiKey: 'sk_...', // Get your API key from https://app.plucky.ai
22
+ })
23
+
24
+ // List all chats
25
+ const { results: chats } = await plucky.chats.list()
26
+ console.log(chats)
27
+
28
+ // Create a new chat
29
+ const chat = await plucky.chats.create({
30
+ title: 'Support Conversation',
31
+ })
32
+
33
+ // Get a specific chat
34
+ const chatDetails = await plucky.chats.find({ id: chat.id })
35
+ ```
36
+
37
+ ## Configuration
38
+
39
+ ```typescript
40
+ import Plucky from '@plucky-ai/node'
41
+
42
+ const plucky = new Plucky({
43
+ // Required: Your API key
44
+ apiKey: 'sk_...',
45
+
46
+ // Optional: Custom base URL (defaults to https://api.plucky.ai)
47
+ baseUrl: 'https://api.plucky.ai',
48
+
49
+ // Optional: Custom fetch implementation
50
+ fetch: customFetch,
51
+ })
52
+ ```
53
+
54
+ ## API Reference
55
+
56
+ ### Chats
57
+
58
+ ```typescript
59
+ // List all chats
60
+ const { results } = await plucky.chats.list()
61
+
62
+ // Create a chat
63
+ const chat = await plucky.chats.create({ title: 'My Chat' })
64
+
65
+ // Get a chat by ID
66
+ const chat = await plucky.chats.find({ id: 'chat_123' })
67
+ ```
68
+
69
+ ### Apps
70
+
71
+ ```typescript
72
+ // List all apps
73
+ const { results } = await plucky.apps.list()
74
+
75
+ // Get an app by ID
76
+ const app = await plucky.apps.find({ id: 'app_123' })
77
+ ```
78
+
79
+ ## Advanced Usage
80
+
81
+ ### Using the raw client
82
+
83
+ For advanced use cases, you can access the underlying typed API client:
84
+
85
+ ```typescript
86
+ import Plucky from '@plucky-ai/node'
87
+
88
+ const plucky = new Plucky({ apiKey: 'sk_...' })
89
+
90
+ // Access the raw client
91
+ const client = plucky.api
92
+ ```
93
+
94
+ ### Using createApiClient directly
95
+
96
+ If you prefer more control, use `createApiClient`:
97
+
98
+ ```typescript
99
+ import { createApiClient } from '@plucky-ai/node'
100
+
101
+ const client = createApiClient({
102
+ apiKey: 'sk_...',
103
+ baseUrl: 'https://api.plucky.ai',
104
+ })
105
+
106
+ const chats = await client.chats.list()
107
+ ```
108
+
109
+ ## TypeScript
110
+
111
+ This package is written in TypeScript and includes full type definitions. All API responses are fully typed.
112
+
113
+ ```typescript
114
+ import Plucky, { type PluckyOptions, type ApiClient } from '@plucky-ai/node'
115
+ ```
116
+
117
+ ## Requirements
118
+
119
+ - Node.js 18.0.0 or later
120
+
121
+ ## License
122
+
123
+ MIT
package/dist/index.cjs ADDED
@@ -0,0 +1,171 @@
1
+ Object.defineProperty(exports, '__esModule', { value: true });
2
+ //#region rolldown:runtime
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
11
+ key = keys[i];
12
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
13
+ get: ((k) => from[k]).bind(null, key),
14
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
+ });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
20
+ value: mod,
21
+ enumerable: true
22
+ }) : target, mod));
23
+
24
+ //#endregion
25
+ let __plucky_ai_api_contracts_client = require("@plucky-ai/api-contracts/client");
26
+ __plucky_ai_api_contracts_client = __toESM(__plucky_ai_api_contracts_client);
27
+ let __orpc_contract = require("@orpc/contract");
28
+ __orpc_contract = __toESM(__orpc_contract);
29
+ let zod = require("zod");
30
+ zod = __toESM(zod);
31
+
32
+ //#region ../api-contracts/dist/src-BsXbfiX4.js
33
+ var apps_default = {
34
+ find: __orpc_contract.oc.route({
35
+ method: "GET",
36
+ path: "/apps/{id}",
37
+ tags: ["Apps"],
38
+ summary: "Get an app",
39
+ description: "Retrieve an app by its ID"
40
+ }).input(zod.default.object({ id: zod.default.string() })).output(zod.default.object({
41
+ id: zod.default.string(),
42
+ name: zod.default.string(),
43
+ createdAt: zod.default.coerce.date()
44
+ })),
45
+ list: __orpc_contract.oc.route({
46
+ method: "GET",
47
+ path: "/apps",
48
+ tags: ["Apps"],
49
+ summary: "List apps",
50
+ description: "Retrieve all apps"
51
+ }).output(zod.default.object({ results: zod.default.array(zod.default.object({
52
+ id: zod.default.string(),
53
+ name: zod.default.string(),
54
+ createdAt: zod.default.coerce.date()
55
+ })) }))
56
+ };
57
+ const ChatSchema = zod.default.object({
58
+ id: zod.default.string(),
59
+ title: zod.default.string(),
60
+ userId: zod.default.string(),
61
+ createdAt: zod.default.coerce.date()
62
+ });
63
+ var chats_default = {
64
+ create: __orpc_contract.oc.route({
65
+ method: "POST",
66
+ path: "/chats",
67
+ tags: ["Chats"],
68
+ summary: "Create a chat",
69
+ description: "Create a new chat session"
70
+ }).input(zod.default.object({
71
+ title: zod.default.string(),
72
+ userId: zod.default.string().min(1)
73
+ })).output(ChatSchema),
74
+ find: __orpc_contract.oc.route({
75
+ method: "GET",
76
+ path: "/chats/{id}",
77
+ tags: ["Chats"],
78
+ summary: "Get a chat",
79
+ description: "Retrieve a chat by its ID"
80
+ }).input(zod.default.object({ id: zod.default.string() })).output(ChatSchema),
81
+ list: __orpc_contract.oc.route({
82
+ method: "GET",
83
+ path: "/chats",
84
+ tags: ["Chats"],
85
+ summary: "List chats",
86
+ description: "Retrieve all chats with pagination support"
87
+ }).input(zod.default.object({
88
+ userId: zod.default.string().min(1).optional(),
89
+ limit: zod.default.coerce.number().int().min(1).max(100).default(20),
90
+ cursor: zod.default.string().optional()
91
+ })).output(zod.default.object({
92
+ results: zod.default.array(ChatSchema),
93
+ nextCursor: zod.default.string().nullable(),
94
+ hasMore: zod.default.boolean()
95
+ }))
96
+ };
97
+ /**
98
+ * Header name constants for the public API
99
+ */
100
+ const API_KEY_HEADER = "x-api-key";
101
+ /**
102
+ * Schema for the API key header
103
+ * API keys are prefixed with 'sk_' (secret key)
104
+ */
105
+ const ApiKeyHeaderSchema = zod.z.string().min(1, "API key is required");
106
+ /**
107
+ * Combined headers schema for all API requests
108
+ */
109
+ const ApiHeadersSchema = zod.z.object({ [API_KEY_HEADER]: ApiKeyHeaderSchema });
110
+ const contract = {
111
+ apps: apps_default,
112
+ chats: chats_default
113
+ };
114
+
115
+ //#endregion
116
+ //#region src/index.ts
117
+ const DEFAULT_BASE_URL = "https://api.plucky.ai";
118
+ /**
119
+ * Plucky API client for Node.js
120
+ *
121
+ * @example
122
+ * ```ts
123
+ * import Plucky from '@plucky-ai/node'
124
+ *
125
+ * const plucky = new Plucky({ apiKey: 'sk_...' })
126
+ *
127
+ * const chats = await plucky.chats.list()
128
+ * ```
129
+ */
130
+ var Plucky = class {
131
+ client;
132
+ /**
133
+ * Access to chat operations
134
+ */
135
+ chats;
136
+ /**
137
+ * Access to app operations
138
+ */
139
+ apps;
140
+ constructor(options) {
141
+ const { apiKey, baseUrl = DEFAULT_BASE_URL, fetch: customFetch } = options;
142
+ if (!apiKey) throw new Error("API key is required. Get one at https://app.plucky.ai");
143
+ this.client = (0, __plucky_ai_api_contracts_client.createApiClient)({
144
+ apiKey,
145
+ baseUrl,
146
+ fetch: customFetch
147
+ });
148
+ this.chats = this.client.chats;
149
+ this.apps = this.client.apps;
150
+ }
151
+ /**
152
+ * Get the underlying API client for advanced use cases
153
+ */
154
+ get api() {
155
+ return this.client;
156
+ }
157
+ };
158
+ var src_default = Plucky;
159
+
160
+ //#endregion
161
+ exports.API_KEY_HEADER = API_KEY_HEADER;
162
+ exports.Plucky = Plucky;
163
+ exports.contract = contract;
164
+ Object.defineProperty(exports, 'createApiClient', {
165
+ enumerable: true,
166
+ get: function () {
167
+ return __plucky_ai_api_contracts_client.createApiClient;
168
+ }
169
+ });
170
+ exports.default = src_default;
171
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","names":["oc","z$1","z"],"sources":["../../api-contracts/dist/src-BsXbfiX4.js","../src/index.ts"],"sourcesContent":["import { oc } from \"@orpc/contract\";\nimport z$1, { z } from \"zod\";\n\n//#region src/apps.ts\nconst findApps = oc.route({\n\tmethod: \"GET\",\n\tpath: \"/apps/{id}\",\n\ttags: [\"Apps\"],\n\tsummary: \"Get an app\",\n\tdescription: \"Retrieve an app by its ID\"\n}).input(z$1.object({ id: z$1.string() })).output(z$1.object({\n\tid: z$1.string(),\n\tname: z$1.string(),\n\tcreatedAt: z$1.coerce.date()\n}));\nconst listApps = oc.route({\n\tmethod: \"GET\",\n\tpath: \"/apps\",\n\ttags: [\"Apps\"],\n\tsummary: \"List apps\",\n\tdescription: \"Retrieve all apps\"\n}).output(z$1.object({ results: z$1.array(z$1.object({\n\tid: z$1.string(),\n\tname: z$1.string(),\n\tcreatedAt: z$1.coerce.date()\n})) }));\nvar apps_default = {\n\tfind: findApps,\n\tlist: listApps\n};\n\n//#endregion\n//#region src/chats.ts\nconst ChatSchema = z$1.object({\n\tid: z$1.string(),\n\ttitle: z$1.string(),\n\tuserId: z$1.string(),\n\tcreatedAt: z$1.coerce.date()\n});\nconst createChat = oc.route({\n\tmethod: \"POST\",\n\tpath: \"/chats\",\n\ttags: [\"Chats\"],\n\tsummary: \"Create a chat\",\n\tdescription: \"Create a new chat session\"\n}).input(z$1.object({\n\ttitle: z$1.string(),\n\tuserId: z$1.string().min(1)\n})).output(ChatSchema);\nconst findChat = oc.route({\n\tmethod: \"GET\",\n\tpath: \"/chats/{id}\",\n\ttags: [\"Chats\"],\n\tsummary: \"Get a chat\",\n\tdescription: \"Retrieve a chat by its ID\"\n}).input(z$1.object({ id: z$1.string() })).output(ChatSchema);\nconst listChats = oc.route({\n\tmethod: \"GET\",\n\tpath: \"/chats\",\n\ttags: [\"Chats\"],\n\tsummary: \"List chats\",\n\tdescription: \"Retrieve all chats with pagination support\"\n}).input(z$1.object({\n\tuserId: z$1.string().min(1).optional(),\n\tlimit: z$1.coerce.number().int().min(1).max(100).default(20),\n\tcursor: z$1.string().optional()\n})).output(z$1.object({\n\tresults: z$1.array(ChatSchema),\n\tnextCursor: z$1.string().nullable(),\n\thasMore: z$1.boolean()\n}));\nvar chats_default = {\n\tcreate: createChat,\n\tfind: findChat,\n\tlist: listChats\n};\n\n//#endregion\n//#region src/headers.ts\n/**\n* Header name constants for the public API\n*/\nconst API_KEY_HEADER = \"x-api-key\";\n/**\n* Schema for the API key header\n* API keys are prefixed with 'sk_' (secret key)\n*/\nconst ApiKeyHeaderSchema = z.string().min(1, \"API key is required\");\n/**\n* Combined headers schema for all API requests\n*/\nconst ApiHeadersSchema = z.object({ [API_KEY_HEADER]: ApiKeyHeaderSchema });\n\n//#endregion\n//#region src/index.ts\nconst contract = {\n\tapps: apps_default,\n\tchats: chats_default\n};\n\n//#endregion\nexport { ApiKeyHeaderSchema as i, API_KEY_HEADER as n, ApiHeadersSchema as r, contract as t };\n//# sourceMappingURL=src-BsXbfiX4.js.map","/**\n * @plucky-ai/node - Official Node.js SDK for the Plucky API\n *\n * @example\n * ```ts\n * import Plucky from '@plucky-ai/node'\n *\n * const plucky = new Plucky({\n * apiKey: 'sk_...',\n * })\n *\n * // List all chats\n * const { results } = await plucky.chats.list()\n *\n * // Create a new chat\n * const chat = await plucky.chats.create({ title: 'New Chat' })\n * ```\n */\n\nexport {\n createApiClient,\n type ApiClient,\n type CreateApiClientOptions,\n} from '@plucky-ai/api-contracts/client'\n\nexport { API_KEY_HEADER, contract } from '@plucky-ai/api-contracts'\n\nimport {\n createApiClient,\n type ApiClient,\n type CreateApiClientOptions,\n} from '@plucky-ai/api-contracts/client'\n\nconst DEFAULT_BASE_URL = 'https://api.plucky.ai'\n\nexport interface PluckyOptions {\n /**\n * Your Plucky API key (starts with 'sk_')\n */\n apiKey: string\n /**\n * Base URL of the Plucky API\n * @default 'https://api.plucky.ai'\n */\n baseUrl?: string\n /**\n * Optional custom fetch implementation for advanced use cases\n */\n fetch?: typeof fetch\n}\n\n/**\n * Plucky API client for Node.js\n *\n * @example\n * ```ts\n * import Plucky from '@plucky-ai/node'\n *\n * const plucky = new Plucky({ apiKey: 'sk_...' })\n *\n * const chats = await plucky.chats.list()\n * ```\n */\nexport class Plucky {\n private client: ApiClient\n\n /**\n * Access to chat operations\n */\n public readonly chats: ApiClient['chats']\n\n /**\n * Access to app operations\n */\n public readonly apps: ApiClient['apps']\n\n constructor(options: PluckyOptions) {\n const { apiKey, baseUrl = DEFAULT_BASE_URL, fetch: customFetch } = options\n\n if (!apiKey) {\n throw new Error('API key is required. Get one at https://app.plucky.ai')\n }\n\n const clientOptions: CreateApiClientOptions = {\n apiKey,\n baseUrl,\n fetch: customFetch,\n }\n\n this.client = createApiClient(clientOptions)\n\n // Expose API resources\n this.chats = this.client.chats\n this.apps = this.client.apps\n }\n\n /**\n * Get the underlying API client for advanced use cases\n */\n get api(): ApiClient {\n return this.client\n }\n}\n\nexport default Plucky\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,IAAI,eAAe;CAClB,MAvBgBA,mBAAG,MAAM;EACzB,QAAQ;EACR,MAAM;EACN,MAAM,CAAC,OAAO;E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f,SAAS;EACT,aAAa;EACb,CAAC,CAAC,MAAMC,YAAI,OAAO;EACnB,QAAQA,YAAI,QAAQ,CAAC,IAAI,EAAE,CAAC,UAAU;EACtC,OAAOA,YAAI,OAAO,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,IAAI,IAAI,CAAC,QAAQ,GAAG;EAC5D,QAAQA,YAAI,QAAQ,CAAC,UAAU;EAC/B,CAAC,CAAC,CAAC,OAAOA,YAAI,OAAO;EACrB,SAASA,YAAI,MAAM,WAAW;EAC9B,YAAYA,YAAI,QAAQ,CAAC,UAAU;EACnC,SAASA,YAAI,SAAS;EACtB,CAAC,CAAC;CAKF;;;;AAOD,MAAM,iBAAiB;;;;;AAKvB,MAAM,qBAAqBC,MAAE,QAAQ,CAAC,IAAI,GAAG,sBAAsB;;;;AAInE,MAAM,mBAAmBA,MAAE,OAAO,GAAG,iBAAiB,oBAAoB,CAAC;AAI3E,MAAM,WAAW;CAChB,MAAM;CACN,OAAO;CACP;;;;ACjED,MAAM,mBAAmB;;;;;;;;;;;;;AA8BzB,IAAa,SAAb,MAAoB;CAClB,AAAQ;;;;CAKR,AAAgB;;;;CAKhB,AAAgB;CAEhB,YAAY,SAAwB;EAClC,MAAM,EAAE,QAAQ,UAAU,kBAAkB,OAAO,gBAAgB;AAEnE,MAAI,CAAC,OACH,OAAM,IAAI,MAAM,wDAAwD;AAS1E,OAAK,+DANyC;GAC5C;GACA;GACA,OAAO;GACR,CAE2C;AAG5C,OAAK,QAAQ,KAAK,OAAO;AACzB,OAAK,OAAO,KAAK,OAAO;;;;;CAM1B,IAAI,MAAiB;AACnB,SAAO,KAAK;;;AAIhB,kBAAe"}
@@ -0,0 +1,51 @@
1
+ import { ApiClient, ApiClient as ApiClient$1, CreateApiClientOptions, createApiClient } from "@plucky-ai/api-contracts/client";
2
+ import { API_KEY_HEADER, contract } from "@plucky-ai/api-contracts";
3
+
4
+ //#region src/index.d.ts
5
+
6
+ interface PluckyOptions {
7
+ /**
8
+ * Your Plucky API key (starts with 'sk_')
9
+ */
10
+ apiKey: string;
11
+ /**
12
+ * Base URL of the Plucky API
13
+ * @default 'https://api.plucky.ai'
14
+ */
15
+ baseUrl?: string;
16
+ /**
17
+ * Optional custom fetch implementation for advanced use cases
18
+ */
19
+ fetch?: typeof fetch;
20
+ }
21
+ /**
22
+ * Plucky API client for Node.js
23
+ *
24
+ * @example
25
+ * ```ts
26
+ * import Plucky from '@plucky-ai/node'
27
+ *
28
+ * const plucky = new Plucky({ apiKey: 'sk_...' })
29
+ *
30
+ * const chats = await plucky.chats.list()
31
+ * ```
32
+ */
33
+ declare class Plucky {
34
+ private client;
35
+ /**
36
+ * Access to chat operations
37
+ */
38
+ readonly chats: ApiClient$1['chats'];
39
+ /**
40
+ * Access to app operations
41
+ */
42
+ readonly apps: ApiClient$1['apps'];
43
+ constructor(options: PluckyOptions);
44
+ /**
45
+ * Get the underlying API client for advanced use cases
46
+ */
47
+ get api(): ApiClient$1;
48
+ }
49
+ //#endregion
50
+ export { API_KEY_HEADER, type ApiClient, type CreateApiClientOptions, Plucky, Plucky as default, PluckyOptions, contract, createApiClient };
51
+ //# sourceMappingURL=index.d.cts.map
@@ -0,0 +1,51 @@
1
+ import { ApiClient, ApiClient as ApiClient$1, CreateApiClientOptions, createApiClient } from "@plucky-ai/api-contracts/client";
2
+ import { API_KEY_HEADER, contract } from "@plucky-ai/api-contracts";
3
+
4
+ //#region src/index.d.ts
5
+
6
+ interface PluckyOptions {
7
+ /**
8
+ * Your Plucky API key (starts with 'sk_')
9
+ */
10
+ apiKey: string;
11
+ /**
12
+ * Base URL of the Plucky API
13
+ * @default 'https://api.plucky.ai'
14
+ */
15
+ baseUrl?: string;
16
+ /**
17
+ * Optional custom fetch implementation for advanced use cases
18
+ */
19
+ fetch?: typeof fetch;
20
+ }
21
+ /**
22
+ * Plucky API client for Node.js
23
+ *
24
+ * @example
25
+ * ```ts
26
+ * import Plucky from '@plucky-ai/node'
27
+ *
28
+ * const plucky = new Plucky({ apiKey: 'sk_...' })
29
+ *
30
+ * const chats = await plucky.chats.list()
31
+ * ```
32
+ */
33
+ declare class Plucky {
34
+ private client;
35
+ /**
36
+ * Access to chat operations
37
+ */
38
+ readonly chats: ApiClient$1['chats'];
39
+ /**
40
+ * Access to app operations
41
+ */
42
+ readonly apps: ApiClient$1['apps'];
43
+ constructor(options: PluckyOptions);
44
+ /**
45
+ * Get the underlying API client for advanced use cases
46
+ */
47
+ get api(): ApiClient$1;
48
+ }
49
+ //#endregion
50
+ export { API_KEY_HEADER, type ApiClient, type CreateApiClientOptions, Plucky, Plucky as default, PluckyOptions, contract, createApiClient };
51
+ //# sourceMappingURL=index.d.ts.map
package/dist/index.js ADDED
@@ -0,0 +1,135 @@
1
+ import { createApiClient, createApiClient as createApiClient$1 } from "@plucky-ai/api-contracts/client";
2
+ import { oc } from "@orpc/contract";
3
+ import z$1, { z } from "zod";
4
+
5
+ //#region ../api-contracts/dist/src-BsXbfiX4.js
6
+ var apps_default = {
7
+ find: oc.route({
8
+ method: "GET",
9
+ path: "/apps/{id}",
10
+ tags: ["Apps"],
11
+ summary: "Get an app",
12
+ description: "Retrieve an app by its ID"
13
+ }).input(z$1.object({ id: z$1.string() })).output(z$1.object({
14
+ id: z$1.string(),
15
+ name: z$1.string(),
16
+ createdAt: z$1.coerce.date()
17
+ })),
18
+ list: oc.route({
19
+ method: "GET",
20
+ path: "/apps",
21
+ tags: ["Apps"],
22
+ summary: "List apps",
23
+ description: "Retrieve all apps"
24
+ }).output(z$1.object({ results: z$1.array(z$1.object({
25
+ id: z$1.string(),
26
+ name: z$1.string(),
27
+ createdAt: z$1.coerce.date()
28
+ })) }))
29
+ };
30
+ const ChatSchema = z$1.object({
31
+ id: z$1.string(),
32
+ title: z$1.string(),
33
+ userId: z$1.string(),
34
+ createdAt: z$1.coerce.date()
35
+ });
36
+ var chats_default = {
37
+ create: oc.route({
38
+ method: "POST",
39
+ path: "/chats",
40
+ tags: ["Chats"],
41
+ summary: "Create a chat",
42
+ description: "Create a new chat session"
43
+ }).input(z$1.object({
44
+ title: z$1.string(),
45
+ userId: z$1.string().min(1)
46
+ })).output(ChatSchema),
47
+ find: oc.route({
48
+ method: "GET",
49
+ path: "/chats/{id}",
50
+ tags: ["Chats"],
51
+ summary: "Get a chat",
52
+ description: "Retrieve a chat by its ID"
53
+ }).input(z$1.object({ id: z$1.string() })).output(ChatSchema),
54
+ list: oc.route({
55
+ method: "GET",
56
+ path: "/chats",
57
+ tags: ["Chats"],
58
+ summary: "List chats",
59
+ description: "Retrieve all chats with pagination support"
60
+ }).input(z$1.object({
61
+ userId: z$1.string().min(1).optional(),
62
+ limit: z$1.coerce.number().int().min(1).max(100).default(20),
63
+ cursor: z$1.string().optional()
64
+ })).output(z$1.object({
65
+ results: z$1.array(ChatSchema),
66
+ nextCursor: z$1.string().nullable(),
67
+ hasMore: z$1.boolean()
68
+ }))
69
+ };
70
+ /**
71
+ * Header name constants for the public API
72
+ */
73
+ const API_KEY_HEADER = "x-api-key";
74
+ /**
75
+ * Schema for the API key header
76
+ * API keys are prefixed with 'sk_' (secret key)
77
+ */
78
+ const ApiKeyHeaderSchema = z.string().min(1, "API key is required");
79
+ /**
80
+ * Combined headers schema for all API requests
81
+ */
82
+ const ApiHeadersSchema = z.object({ [API_KEY_HEADER]: ApiKeyHeaderSchema });
83
+ const contract = {
84
+ apps: apps_default,
85
+ chats: chats_default
86
+ };
87
+
88
+ //#endregion
89
+ //#region src/index.ts
90
+ const DEFAULT_BASE_URL = "https://api.plucky.ai";
91
+ /**
92
+ * Plucky API client for Node.js
93
+ *
94
+ * @example
95
+ * ```ts
96
+ * import Plucky from '@plucky-ai/node'
97
+ *
98
+ * const plucky = new Plucky({ apiKey: 'sk_...' })
99
+ *
100
+ * const chats = await plucky.chats.list()
101
+ * ```
102
+ */
103
+ var Plucky = class {
104
+ client;
105
+ /**
106
+ * Access to chat operations
107
+ */
108
+ chats;
109
+ /**
110
+ * Access to app operations
111
+ */
112
+ apps;
113
+ constructor(options) {
114
+ const { apiKey, baseUrl = DEFAULT_BASE_URL, fetch: customFetch } = options;
115
+ if (!apiKey) throw new Error("API key is required. Get one at https://app.plucky.ai");
116
+ this.client = createApiClient$1({
117
+ apiKey,
118
+ baseUrl,
119
+ fetch: customFetch
120
+ });
121
+ this.chats = this.client.chats;
122
+ this.apps = this.client.apps;
123
+ }
124
+ /**
125
+ * Get the underlying API client for advanced use cases
126
+ */
127
+ get api() {
128
+ return this.client;
129
+ }
130
+ };
131
+ var src_default = Plucky;
132
+
133
+ //#endregion
134
+ export { API_KEY_HEADER, Plucky, contract, createApiClient, src_default as default };
135
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["createApiClient"],"sources":["../../api-contracts/dist/src-BsXbfiX4.js","../src/index.ts"],"sourcesContent":["import { oc } from \"@orpc/contract\";\nimport z$1, { z } from \"zod\";\n\n//#region src/apps.ts\nconst findApps = oc.route({\n\tmethod: \"GET\",\n\tpath: \"/apps/{id}\",\n\ttags: [\"Apps\"],\n\tsummary: \"Get an app\",\n\tdescription: \"Retrieve an app by its ID\"\n}).input(z$1.object({ id: z$1.string() })).output(z$1.object({\n\tid: z$1.string(),\n\tname: z$1.string(),\n\tcreatedAt: z$1.coerce.date()\n}));\nconst listApps = oc.route({\n\tmethod: \"GET\",\n\tpath: \"/apps\",\n\ttags: [\"Apps\"],\n\tsummary: \"List apps\",\n\tdescription: \"Retrieve all apps\"\n}).output(z$1.object({ results: z$1.array(z$1.object({\n\tid: z$1.string(),\n\tname: z$1.string(),\n\tcreatedAt: z$1.coerce.date()\n})) }));\nvar apps_default = {\n\tfind: findApps,\n\tlist: listApps\n};\n\n//#endregion\n//#region src/chats.ts\nconst ChatSchema = z$1.object({\n\tid: z$1.string(),\n\ttitle: z$1.string(),\n\tuserId: z$1.string(),\n\tcreatedAt: z$1.coerce.date()\n});\nconst createChat = oc.route({\n\tmethod: \"POST\",\n\tpath: \"/chats\",\n\ttags: [\"Chats\"],\n\tsummary: \"Create a chat\",\n\tdescription: \"Create a new chat session\"\n}).input(z$1.object({\n\ttitle: z$1.string(),\n\tuserId: z$1.string().min(1)\n})).output(ChatSchema);\nconst findChat = oc.route({\n\tmethod: \"GET\",\n\tpath: \"/chats/{id}\",\n\ttags: [\"Chats\"],\n\tsummary: \"Get a chat\",\n\tdescription: \"Retrieve a chat by its ID\"\n}).input(z$1.object({ id: z$1.string() })).output(ChatSchema);\nconst listChats = oc.route({\n\tmethod: \"GET\",\n\tpath: \"/chats\",\n\ttags: [\"Chats\"],\n\tsummary: \"List chats\",\n\tdescription: \"Retrieve all chats with pagination support\"\n}).input(z$1.object({\n\tuserId: z$1.string().min(1).optional(),\n\tlimit: z$1.coerce.number().int().min(1).max(100).default(20),\n\tcursor: z$1.string().optional()\n})).output(z$1.object({\n\tresults: z$1.array(ChatSchema),\n\tnextCursor: z$1.string().nullable(),\n\thasMore: z$1.boolean()\n}));\nvar chats_default = {\n\tcreate: createChat,\n\tfind: findChat,\n\tlist: listChats\n};\n\n//#endregion\n//#region src/headers.ts\n/**\n* Header name constants for the public API\n*/\nconst API_KEY_HEADER = \"x-api-key\";\n/**\n* Schema for the API key header\n* API keys are prefixed with 'sk_' (secret key)\n*/\nconst ApiKeyHeaderSchema = z.string().min(1, \"API key is required\");\n/**\n* Combined headers schema for all API requests\n*/\nconst ApiHeadersSchema = z.object({ [API_KEY_HEADER]: ApiKeyHeaderSchema });\n\n//#endregion\n//#region src/index.ts\nconst contract = {\n\tapps: apps_default,\n\tchats: chats_default\n};\n\n//#endregion\nexport { ApiKeyHeaderSchema as i, API_KEY_HEADER as n, ApiHeadersSchema as r, contract as t };\n//# sourceMappingURL=src-BsXbfiX4.js.map","/**\n * @plucky-ai/node - Official Node.js SDK for the Plucky API\n *\n * @example\n * ```ts\n * import Plucky from '@plucky-ai/node'\n *\n * const plucky = new Plucky({\n * apiKey: 'sk_...',\n * })\n *\n * // List all chats\n * const { results } = await plucky.chats.list()\n *\n * // Create a new chat\n * const chat = await plucky.chats.create({ title: 'New Chat' })\n * ```\n */\n\nexport {\n createApiClient,\n type ApiClient,\n type CreateApiClientOptions,\n} from '@plucky-ai/api-contracts/client'\n\nexport { API_KEY_HEADER, contract } from '@plucky-ai/api-contracts'\n\nimport {\n createApiClient,\n type ApiClient,\n type CreateApiClientOptions,\n} from '@plucky-ai/api-contracts/client'\n\nconst DEFAULT_BASE_URL = 'https://api.plucky.ai'\n\nexport interface PluckyOptions {\n /**\n * Your Plucky API key (starts with 'sk_')\n */\n apiKey: string\n /**\n * Base URL of the Plucky API\n * @default 'https://api.plucky.ai'\n */\n baseUrl?: string\n /**\n * Optional custom fetch implementation for advanced use cases\n */\n fetch?: typeof fetch\n}\n\n/**\n * Plucky API client for Node.js\n *\n * @example\n * ```ts\n * import Plucky from '@plucky-ai/node'\n *\n * const plucky = new Plucky({ apiKey: 'sk_...' })\n *\n * const chats = await plucky.chats.list()\n * ```\n */\nexport class Plucky {\n private client: ApiClient\n\n /**\n * Access to chat operations\n */\n public readonly chats: ApiClient['chats']\n\n /**\n * Access to app operations\n */\n public readonly apps: ApiClient['apps']\n\n constructor(options: PluckyOptions) {\n const { apiKey, baseUrl = DEFAULT_BASE_URL, fetch: customFetch } = options\n\n if (!apiKey) {\n throw new Error('API key is required. Get one at https://app.plucky.ai')\n }\n\n const clientOptions: CreateApiClientOptions = {\n apiKey,\n baseUrl,\n fetch: customFetch,\n }\n\n this.client = createApiClient(clientOptions)\n\n // Expose API resources\n this.chats = this.client.chats\n this.apps = this.client.apps\n }\n\n /**\n * Get the underlying API client for advanced use cases\n */\n get api(): ApiClient {\n return this.client\n }\n}\n\nexport default Plucky\n"],"mappings":";;;;;AA0BA,IAAI,eAAe;CAClB,MAvBgB,GAAG,MAAM;EACzB,QAAQ;EACR,MAAM;EACN,MAAM,CAAC,OAAO;EACd,SAAS;EACT,aAAa;EACb,CAAC,CAAC,MAAM,IAAI,OAAO,EAAE,IAAI,IAAI,QAAQ,E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C,OAAO,IAAI,OAAO,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,IAAI,IAAI,CAAC,QAAQ,GAAG;EAC5D,QAAQ,IAAI,QAAQ,CAAC,UAAU;EAC/B,CAAC,CAAC,CAAC,OAAO,IAAI,OAAO;EACrB,SAAS,IAAI,MAAM,WAAW;EAC9B,YAAY,IAAI,QAAQ,CAAC,UAAU;EACnC,SAAS,IAAI,SAAS;EACtB,CAAC,CAAC;CAKF;;;;AAOD,MAAM,iBAAiB;;;;;AAKvB,MAAM,qBAAqB,EAAE,QAAQ,CAAC,IAAI,GAAG,sBAAsB;;;;AAInE,MAAM,mBAAmB,EAAE,OAAO,GAAG,iBAAiB,oBAAoB,CAAC;AAI3E,MAAM,WAAW;CAChB,MAAM;CACN,OAAO;CACP;;;;ACjED,MAAM,mBAAmB;;;;;;;;;;;;;AA8BzB,IAAa,SAAb,MAAoB;CAClB,AAAQ;;;;CAKR,AAAgB;;;;CAKhB,AAAgB;CAEhB,YAAY,SAAwB;EAClC,MAAM,EAAE,QAAQ,UAAU,kBAAkB,OAAO,gBAAgB;AAEnE,MAAI,CAAC,OACH,OAAM,IAAI,MAAM,wDAAwD;AAS1E,OAAK,SAASA,kBANgC;GAC5C;GACA;GACA,OAAO;GACR,CAE2C;AAG5C,OAAK,QAAQ,KAAK,OAAO;AACzB,OAAK,OAAO,KAAK,OAAO;;;;;CAM1B,IAAI,MAAiB;AACnB,SAAO,KAAK;;;AAIhB,kBAAe"}
@@ -0,0 +1,23 @@
1
+ {
2
+ "name": "@plucky-ai/node",
3
+ "version": "0.2.0",
4
+ "type": "module",
5
+ "main": "./index.cjs",
6
+ "module": "./index.js",
7
+ "types": "./index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js",
12
+ "require": "./dist/index.cjs"
13
+ }
14
+ },
15
+ "files": [
16
+ "*.js",
17
+ "*.mjs",
18
+ "*.cjs",
19
+ "*.d.ts",
20
+ "*.map"
21
+ ],
22
+ "sideEffects": false
23
+ }
package/package.json ADDED
@@ -0,0 +1,60 @@
1
+ {
2
+ "name": "@plucky-ai/node",
3
+ "version": "0.2.0",
4
+ "description": "Official Node.js SDK for the Plucky API",
5
+ "type": "module",
6
+ "main": "./dist/index.cjs",
7
+ "module": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.js",
13
+ "require": "./dist/index.cjs"
14
+ }
15
+ },
16
+ "files": [
17
+ "dist",
18
+ "README.md"
19
+ ],
20
+ "scripts": {
21
+ "build:watch": "pnpm exec tsdown --watch ./src",
22
+ "build": "pnpm exec tsdown"
23
+ },
24
+ "keywords": [
25
+ "plucky",
26
+ "ai",
27
+ "api",
28
+ "sdk",
29
+ "node",
30
+ "typescript"
31
+ ],
32
+ "author": "Plucky AI",
33
+ "license": "MIT",
34
+ "repository": {
35
+ "type": "git",
36
+ "url": "https://github.com/plucky-ai/plucky",
37
+ "directory": "packages/api-node"
38
+ },
39
+ "homepage": "https://docs.plucky.ai",
40
+ "dependencies": {
41
+ "@orpc/client": "^1.8.9",
42
+ "@orpc/contract": "^1.8.9",
43
+ "@orpc/openapi-client": "^1.8.9",
44
+ "@plucky-ai/api-contracts": "workspace:^",
45
+ "zod": "catalog:"
46
+ },
47
+ "devDependencies": {
48
+ "@types/node": "catalog:",
49
+ "tsdown": "catalog:",
50
+ "tsx": "catalog:",
51
+ "typescript": "catalog:"
52
+ },
53
+ "engines": {
54
+ "node": ">=18.0.0"
55
+ },
56
+ "publishConfig": {
57
+ "access": "public",
58
+ "registry": "https://registry.npmjs.org/"
59
+ }
60
+ }