skedyul 0.1.16 → 0.1.18

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/config.d.ts CHANGED
@@ -118,12 +118,12 @@ export interface WorkflowAction {
118
118
  inputs?: WorkflowActionInput[];
119
119
  }
120
120
  export interface WorkflowDefinition {
121
- /** Human-readable label */
122
- label: string;
123
- /** Workflow handle/key */
124
- handle: string;
125
- /** Which channel handle this workflow is associated with (optional) */
126
- channelHandle?: string;
121
+ /** Path to external YAML workflow file (relative to config) */
122
+ path: string;
123
+ /** Human-readable label (optional when path is provided, inferred from YAML) */
124
+ label?: string;
125
+ /** Workflow handle/key (optional when path is provided, inferred from YAML) */
126
+ handle?: string;
127
127
  /** Actions in this workflow */
128
128
  actions: WorkflowAction[];
129
129
  }
package/dist/config.js CHANGED
@@ -231,11 +231,15 @@ function validateConfig(config) {
231
231
  if (config.workflows) {
232
232
  for (let i = 0; i < config.workflows.length; i++) {
233
233
  const workflow = config.workflows[i];
234
- if (!workflow.handle) {
235
- errors.push(`workflows[${i}]: Missing required field 'handle'`);
236
- }
237
- if (!workflow.label) {
238
- errors.push(`workflows[${i}]: Missing required field 'label'`);
234
+ // When path is provided, handle and label are optional (inferred from YAML)
235
+ // When path is not provided, handle and label are required
236
+ if (!workflow.path) {
237
+ if (!workflow.handle) {
238
+ errors.push(`workflows[${i}]: Missing required field 'handle' (required when 'path' is not provided)`);
239
+ }
240
+ if (!workflow.label) {
241
+ errors.push(`workflows[${i}]: Missing required field 'label' (required when 'path' is not provided)`);
242
+ }
239
243
  }
240
244
  if (!workflow.actions || workflow.actions.length === 0) {
241
245
  errors.push(`workflows[${i}]: Must have at least one action`);
@@ -1,13 +1,52 @@
1
1
  import type { CommunicationChannel, Workplace } from './types';
2
+ type ClientConfig = {
3
+ /** Base URL for the Skedyul Core API (e.g., "https://app.skedyul.com/api") */
4
+ baseUrl: string;
5
+ /** API token (sk_app_* for App API or sk_wkp_* for Workplace API) */
6
+ apiToken: string;
7
+ };
8
+ /**
9
+ * Configure the Skedyul client.
10
+ *
11
+ * Can be called to override environment variables, or to set config at runtime.
12
+ *
13
+ * @example
14
+ * ```ts
15
+ * import { configure } from 'skedyul';
16
+ *
17
+ * configure({
18
+ * baseUrl: 'https://app.skedyul.com/api',
19
+ * apiToken: 'sk_app_xxxxx',
20
+ * });
21
+ * ```
22
+ */
23
+ export declare function configure(options: Partial<ClientConfig>): void;
24
+ /**
25
+ * Get the current client configuration.
26
+ */
27
+ export declare function getConfig(): Readonly<ClientConfig>;
2
28
  type ListArgs = {
3
29
  filter?: Record<string, unknown>;
30
+ limit?: number;
4
31
  };
5
32
  export declare const workplace: {
6
33
  list(args?: ListArgs): Promise<Workplace[]>;
7
34
  get(id: string): Promise<Workplace>;
8
35
  };
9
36
  export declare const communicationChannel: {
10
- list(filter?: Record<string, unknown>): Promise<CommunicationChannel[]>;
11
- get(id: string): Promise<CommunicationChannel>;
37
+ /**
38
+ * List communication channels with optional filters.
39
+ *
40
+ * @example
41
+ * ```ts
42
+ * // Find channel by phone number
43
+ * const channels = await communicationChannel.list({
44
+ * filter: { identifierValue: '+1234567890' },
45
+ * limit: 1,
46
+ * });
47
+ * ```
48
+ */
49
+ list(args?: ListArgs): Promise<CommunicationChannel[]>;
50
+ get(id: string): Promise<CommunicationChannel | null>;
12
51
  };
13
52
  export {};
@@ -1,16 +1,60 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.communicationChannel = exports.workplace = void 0;
4
- const CORE_BASE = process.env.SKEDYUL_NODE_URL ?? '';
4
+ exports.configure = configure;
5
+ exports.getConfig = getConfig;
6
+ let config = {
7
+ baseUrl: process.env.SKEDYUL_API_URL ?? process.env.SKEDYUL_NODE_URL ?? '',
8
+ apiToken: process.env.SKEDYUL_API_TOKEN ?? '',
9
+ };
10
+ /**
11
+ * Configure the Skedyul client.
12
+ *
13
+ * Can be called to override environment variables, or to set config at runtime.
14
+ *
15
+ * @example
16
+ * ```ts
17
+ * import { configure } from 'skedyul';
18
+ *
19
+ * configure({
20
+ * baseUrl: 'https://app.skedyul.com/api',
21
+ * apiToken: 'sk_app_xxxxx',
22
+ * });
23
+ * ```
24
+ */
25
+ function configure(options) {
26
+ config = {
27
+ ...config,
28
+ ...options,
29
+ };
30
+ }
31
+ /**
32
+ * Get the current client configuration.
33
+ */
34
+ function getConfig() {
35
+ return config;
36
+ }
37
+ // ─────────────────────────────────────────────────────────────────────────────
38
+ // Core API Client
39
+ // ─────────────────────────────────────────────────────────────────────────────
5
40
  async function callCore(method, params) {
6
- const response = await fetch(`${CORE_BASE}/core`, {
41
+ const { baseUrl, apiToken } = config;
42
+ if (!baseUrl) {
43
+ throw new Error('Skedyul client not configured: missing baseUrl. Set SKEDYUL_API_URL environment variable or call configure().');
44
+ }
45
+ if (!apiToken) {
46
+ throw new Error('Skedyul client not configured: missing apiToken. Set SKEDYUL_API_TOKEN environment variable or call configure().');
47
+ }
48
+ const headers = {
49
+ 'Content-Type': 'application/json',
50
+ Authorization: `Bearer ${apiToken}`,
51
+ };
52
+ const response = await fetch(`${baseUrl}/core`, {
7
53
  method: 'POST',
8
- headers: {
9
- 'Content-Type': 'application/json',
10
- },
54
+ headers,
11
55
  body: JSON.stringify({ method, params }),
12
56
  });
13
- const payload = await response.json();
57
+ const payload = (await response.json());
14
58
  if (!response.ok) {
15
59
  throw new Error(payload?.error?.message ?? `Core API error (${response.status})`);
16
60
  }
@@ -18,21 +62,39 @@ async function callCore(method, params) {
18
62
  }
19
63
  exports.workplace = {
20
64
  async list(args) {
21
- const payload = await callCore('workplace.list', args?.filter ? { filter: args.filter } : undefined);
65
+ const payload = (await callCore('workplace.list', {
66
+ ...(args?.filter ? { filter: args.filter } : {}),
67
+ ...(args?.limit ? { limit: args.limit } : {}),
68
+ }));
22
69
  return payload.workplaces;
23
70
  },
24
71
  async get(id) {
25
- const payload = await callCore('workplace.get', { id });
72
+ const payload = (await callCore('workplace.get', { id }));
26
73
  return payload.workplace;
27
74
  },
28
75
  };
29
76
  exports.communicationChannel = {
30
- async list(filter) {
31
- const payload = await callCore('communicationChannel.list', filter ? { filter } : undefined);
77
+ /**
78
+ * List communication channels with optional filters.
79
+ *
80
+ * @example
81
+ * ```ts
82
+ * // Find channel by phone number
83
+ * const channels = await communicationChannel.list({
84
+ * filter: { identifierValue: '+1234567890' },
85
+ * limit: 1,
86
+ * });
87
+ * ```
88
+ */
89
+ async list(args) {
90
+ const payload = (await callCore('communicationChannel.list', {
91
+ ...(args?.filter ? { filter: args.filter } : {}),
92
+ ...(args?.limit ? { limit: args.limit } : {}),
93
+ }));
32
94
  return payload.channels;
33
95
  },
34
96
  async get(id) {
35
- const payload = await callCore('communicationChannel.get', { id });
97
+ const payload = (await callCore('communicationChannel.get', { id }));
36
98
  return payload.channel;
37
99
  },
38
100
  };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export * from './types';
2
2
  export { server } from './server';
3
- export { workplace, communicationChannel } from './core/client';
3
+ export { workplace, communicationChannel, configure, getConfig } from './core/client';
4
4
  export { defineConfig, loadConfig, validateConfig, getRequiredInstallEnvKeys, getAllEnvKeys, CONFIG_FILE_NAMES, } from './config';
5
5
  export type { SkedyulConfig, EnvVariableDefinition, EnvSchema, EnvVisibility, InstallConfig, AppModelDefinition, ComputeLayerType, AppFieldVisibility, AppFieldDefinition, ChannelToolBindings, ChannelIdentifierType, ChannelIdentifierValue, CommunicationChannelDefinition, WorkflowActionInput, WorkflowAction, WorkflowDefinition, } from './config';
package/dist/index.js CHANGED
@@ -14,13 +14,15 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.CONFIG_FILE_NAMES = exports.getAllEnvKeys = exports.getRequiredInstallEnvKeys = exports.validateConfig = exports.loadConfig = exports.defineConfig = exports.communicationChannel = exports.workplace = exports.server = void 0;
17
+ exports.CONFIG_FILE_NAMES = exports.getAllEnvKeys = exports.getRequiredInstallEnvKeys = exports.validateConfig = exports.loadConfig = exports.defineConfig = exports.getConfig = exports.configure = exports.communicationChannel = exports.workplace = exports.server = void 0;
18
18
  __exportStar(require("./types"), exports);
19
19
  var server_1 = require("./server");
20
20
  Object.defineProperty(exports, "server", { enumerable: true, get: function () { return server_1.server; } });
21
21
  var client_1 = require("./core/client");
22
22
  Object.defineProperty(exports, "workplace", { enumerable: true, get: function () { return client_1.workplace; } });
23
23
  Object.defineProperty(exports, "communicationChannel", { enumerable: true, get: function () { return client_1.communicationChannel; } });
24
+ Object.defineProperty(exports, "configure", { enumerable: true, get: function () { return client_1.configure; } });
25
+ Object.defineProperty(exports, "getConfig", { enumerable: true, get: function () { return client_1.getConfig; } });
24
26
  var config_1 = require("./config");
25
27
  Object.defineProperty(exports, "defineConfig", { enumerable: true, get: function () { return config_1.defineConfig; } });
26
28
  Object.defineProperty(exports, "loadConfig", { enumerable: true, get: function () { return config_1.loadConfig; } });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "skedyul",
3
- "version": "0.1.16",
3
+ "version": "0.1.18",
4
4
  "description": "The Skedyul SDK for Node.js",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -34,5 +34,4 @@
34
34
  "@types/node": "^24.10.1",
35
35
  "typescript": "^5.5.0"
36
36
  }
37
- }
38
-
37
+ }