@langslide/sdk 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 +708 -0
- package/dist/api/auth.d.ts +18 -0
- package/dist/api/auth.d.ts.map +1 -0
- package/dist/api/auth.js +43 -0
- package/dist/api/auth.js.map +1 -0
- package/dist/api/integrations.d.ts +27 -0
- package/dist/api/integrations.d.ts.map +1 -0
- package/dist/api/integrations.js +64 -0
- package/dist/api/integrations.js.map +1 -0
- package/dist/api/mcp.d.ts +15 -0
- package/dist/api/mcp.d.ts.map +1 -0
- package/dist/api/mcp.js +24 -0
- package/dist/api/mcp.js.map +1 -0
- package/dist/api/recipes.d.ts +19 -0
- package/dist/api/recipes.d.ts.map +1 -0
- package/dist/api/recipes.js +37 -0
- package/dist/api/recipes.js.map +1 -0
- package/dist/api/users.d.ts +19 -0
- package/dist/api/users.d.ts.map +1 -0
- package/dist/api/users.js +32 -0
- package/dist/api/users.js.map +1 -0
- package/dist/api/workflows.d.ts +44 -0
- package/dist/api/workflows.d.ts.map +1 -0
- package/dist/api/workflows.js +95 -0
- package/dist/api/workflows.js.map +1 -0
- package/dist/browser.js +2 -0
- package/dist/browser.js.map +1 -0
- package/dist/client.d.ts +35 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +87 -0
- package/dist/client.js.map +1 -0
- package/dist/config.d.ts +21 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +39 -0
- package/dist/config.js.map +1 -0
- package/dist/errors.d.ts +39 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +92 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +36 -0
- package/dist/index.js.map +1 -0
- package/dist/react/LangslideProvider.d.ts +12 -0
- package/dist/react/LangslideProvider.d.ts.map +1 -0
- package/dist/react/LangslideProvider.js +87 -0
- package/dist/react/LangslideProvider.js.map +1 -0
- package/dist/react/api/auth.d.ts +18 -0
- package/dist/react/api/auth.d.ts.map +1 -0
- package/dist/react/api/auth.js +43 -0
- package/dist/react/api/auth.js.map +1 -0
- package/dist/react/api/integrations.d.ts +27 -0
- package/dist/react/api/integrations.d.ts.map +1 -0
- package/dist/react/api/integrations.js +64 -0
- package/dist/react/api/integrations.js.map +1 -0
- package/dist/react/api/mcp.d.ts +15 -0
- package/dist/react/api/mcp.d.ts.map +1 -0
- package/dist/react/api/mcp.js +24 -0
- package/dist/react/api/mcp.js.map +1 -0
- package/dist/react/api/recipes.d.ts +19 -0
- package/dist/react/api/recipes.d.ts.map +1 -0
- package/dist/react/api/recipes.js +37 -0
- package/dist/react/api/recipes.js.map +1 -0
- package/dist/react/api/users.d.ts +19 -0
- package/dist/react/api/users.d.ts.map +1 -0
- package/dist/react/api/users.js +32 -0
- package/dist/react/api/users.js.map +1 -0
- package/dist/react/api/workflows.d.ts +44 -0
- package/dist/react/api/workflows.d.ts.map +1 -0
- package/dist/react/api/workflows.js +95 -0
- package/dist/react/api/workflows.js.map +1 -0
- package/dist/react/client.d.ts +35 -0
- package/dist/react/client.d.ts.map +1 -0
- package/dist/react/client.js +87 -0
- package/dist/react/client.js.map +1 -0
- package/dist/react/config.d.ts +21 -0
- package/dist/react/config.d.ts.map +1 -0
- package/dist/react/config.js +39 -0
- package/dist/react/config.js.map +1 -0
- package/dist/react/errors.d.ts +39 -0
- package/dist/react/errors.d.ts.map +1 -0
- package/dist/react/errors.js +92 -0
- package/dist/react/errors.js.map +1 -0
- package/dist/react/index.d.ts +10 -0
- package/dist/react/index.d.ts.map +1 -0
- package/dist/react/index.js +18 -0
- package/dist/react/index.js.map +1 -0
- package/dist/react/react/LangslideProvider.d.ts +19 -0
- package/dist/react/react/LangslideProvider.d.ts.map +1 -0
- package/dist/react/react/LangslideProvider.js +87 -0
- package/dist/react/react/LangslideProvider.js.map +1 -0
- package/dist/react/react/index.d.ts +10 -0
- package/dist/react/react/index.d.ts.map +1 -0
- package/dist/react/react/index.js +18 -0
- package/dist/react/react/index.js.map +1 -0
- package/dist/react/react/useIntegrations.d.ts +13 -0
- package/dist/react/react/useIntegrations.d.ts.map +1 -0
- package/dist/react/react/useIntegrations.js +70 -0
- package/dist/react/react/useIntegrations.js.map +1 -0
- package/dist/react/react/useWorkflows.d.ts +14 -0
- package/dist/react/react/useWorkflows.d.ts.map +1 -0
- package/dist/react/react/useWorkflows.js +108 -0
- package/dist/react/react/useWorkflows.js.map +1 -0
- package/dist/react/types/common.d.ts +28 -0
- package/dist/react/types/common.d.ts.map +1 -0
- package/dist/react/types/common.js +6 -0
- package/dist/react/types/common.js.map +1 -0
- package/dist/react/types/index.d.ts +8 -0
- package/dist/react/types/index.d.ts.map +1 -0
- package/dist/react/types/index.js +25 -0
- package/dist/react/types/index.js.map +1 -0
- package/dist/react/types/integration.d.ts +23 -0
- package/dist/react/types/integration.d.ts.map +1 -0
- package/dist/react/types/integration.js +6 -0
- package/dist/react/types/integration.js.map +1 -0
- package/dist/react/types/permissions.d.ts +31 -0
- package/dist/react/types/permissions.d.ts.map +1 -0
- package/dist/react/types/permissions.js +33 -0
- package/dist/react/types/permissions.js.map +1 -0
- package/dist/react/types/workflow.d.ts +33 -0
- package/dist/react/types/workflow.d.ts.map +1 -0
- package/dist/react/types/workflow.js +6 -0
- package/dist/react/types/workflow.js.map +1 -0
- package/dist/react/useIntegrations.d.ts +13 -0
- package/dist/react/useIntegrations.d.ts.map +1 -0
- package/dist/react/useIntegrations.js +70 -0
- package/dist/react/useIntegrations.js.map +1 -0
- package/dist/react/useWorkflows.d.ts +14 -0
- package/dist/react/useWorkflows.d.ts.map +1 -0
- package/dist/react/useWorkflows.js +108 -0
- package/dist/react/useWorkflows.js.map +1 -0
- package/dist/react/utils/permission-guard.d.ts +13 -0
- package/dist/react/utils/permission-guard.d.ts.map +1 -0
- package/dist/react/utils/permission-guard.js +28 -0
- package/dist/react/utils/permission-guard.js.map +1 -0
- package/dist/react/utils/permissions.d.ts +20 -0
- package/dist/react/utils/permissions.d.ts.map +1 -0
- package/dist/react/utils/permissions.js +48 -0
- package/dist/react/utils/permissions.js.map +1 -0
- package/dist/react/utils/request.d.ts +7 -0
- package/dist/react/utils/request.d.ts.map +1 -0
- package/dist/react/utils/request.js +48 -0
- package/dist/react/utils/request.js.map +1 -0
- package/dist/types/auth.d.ts +5 -0
- package/dist/types/auth.d.ts.map +1 -0
- package/dist/types/auth.js +7 -0
- package/dist/types/auth.js.map +1 -0
- package/dist/types/common.d.ts +28 -0
- package/dist/types/common.d.ts.map +1 -0
- package/dist/types/common.js +6 -0
- package/dist/types/common.js.map +1 -0
- package/dist/types/index.d.ts +8 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +25 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/integration.d.ts +23 -0
- package/dist/types/integration.d.ts.map +1 -0
- package/dist/types/integration.js +6 -0
- package/dist/types/integration.js.map +1 -0
- package/dist/types/permissions.d.ts +31 -0
- package/dist/types/permissions.d.ts.map +1 -0
- package/dist/types/permissions.js +33 -0
- package/dist/types/permissions.js.map +1 -0
- package/dist/types/workflow.d.ts +33 -0
- package/dist/types/workflow.d.ts.map +1 -0
- package/dist/types/workflow.js +6 -0
- package/dist/types/workflow.js.map +1 -0
- package/dist/utils/permission-guard.d.ts +13 -0
- package/dist/utils/permission-guard.d.ts.map +1 -0
- package/dist/utils/permission-guard.js +28 -0
- package/dist/utils/permission-guard.js.map +1 -0
- package/dist/utils/permissions.d.ts +20 -0
- package/dist/utils/permissions.d.ts.map +1 -0
- package/dist/utils/permissions.js +48 -0
- package/dist/utils/permissions.js.map +1 -0
- package/dist/utils/request.d.ts +7 -0
- package/dist/utils/request.d.ts.map +1 -0
- package/dist/utils/request.js +48 -0
- package/dist/utils/request.js.map +1 -0
- package/dist/utils/validation.d.ts +8 -0
- package/dist/utils/validation.d.ts.map +1 -0
- package/dist/utils/validation.js +37 -0
- package/dist/utils/validation.js.map +1 -0
- package/package.json +76 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"integration.js","sourceRoot":"","sources":["../../../src/types/integration.ts"],"names":[],"mappings":";AAAA;;GAEG"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* API Key Permissions
|
|
3
|
+
*/
|
|
4
|
+
export interface IAPIKeyPermissions {
|
|
5
|
+
sdk_methods: string[];
|
|
6
|
+
connectors: string[];
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* SDK Method Permissions
|
|
10
|
+
*/
|
|
11
|
+
export declare const SDK_METHODS: {
|
|
12
|
+
readonly WORKFLOWS_READ: "workflows:read";
|
|
13
|
+
readonly WORKFLOWS_WRITE: "workflows:write";
|
|
14
|
+
readonly CONNECTORS_READ: "connectors:read";
|
|
15
|
+
readonly CONNECTORS_WRITE: "connectors:write";
|
|
16
|
+
readonly INTEGRATIONS_READ: "integrations:read";
|
|
17
|
+
readonly INTEGRATIONS_WRITE: "integrations:write";
|
|
18
|
+
readonly USERS_READ: "users:read";
|
|
19
|
+
readonly USERS_WRITE: "users:write";
|
|
20
|
+
readonly MCP_READ: "mcp:read";
|
|
21
|
+
readonly MCP_WRITE: "mcp:write";
|
|
22
|
+
readonly RECIPES_READ: "recipes:read";
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Permission Presets
|
|
26
|
+
*/
|
|
27
|
+
export declare const PERMISSION_PRESETS: {
|
|
28
|
+
readonly READ_ONLY: readonly ["workflows:read", "connectors:read", "integrations:read", "users:read", "recipes:read"];
|
|
29
|
+
readonly FULL_ACCESS: ("workflows:read" | "workflows:write" | "connectors:read" | "connectors:write" | "integrations:read" | "integrations:write" | "users:read" | "users:write" | "mcp:read" | "mcp:write" | "recipes:read")[];
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=permissions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"permissions.d.ts","sourceRoot":"","sources":["../../../src/types/permissions.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB;AAED;;GAEG;AACH,eAAO,MAAM,WAAW;;;;;;;;;;;;CAYd,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,kBAAkB;;;CASrB,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PERMISSION_PRESETS = exports.SDK_METHODS = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* SDK Method Permissions
|
|
6
|
+
*/
|
|
7
|
+
exports.SDK_METHODS = {
|
|
8
|
+
WORKFLOWS_READ: 'workflows:read',
|
|
9
|
+
WORKFLOWS_WRITE: 'workflows:write',
|
|
10
|
+
CONNECTORS_READ: 'connectors:read',
|
|
11
|
+
CONNECTORS_WRITE: 'connectors:write',
|
|
12
|
+
INTEGRATIONS_READ: 'integrations:read',
|
|
13
|
+
INTEGRATIONS_WRITE: 'integrations:write',
|
|
14
|
+
USERS_READ: 'users:read',
|
|
15
|
+
USERS_WRITE: 'users:write',
|
|
16
|
+
MCP_READ: 'mcp:read',
|
|
17
|
+
MCP_WRITE: 'mcp:write',
|
|
18
|
+
RECIPES_READ: 'recipes:read',
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Permission Presets
|
|
22
|
+
*/
|
|
23
|
+
exports.PERMISSION_PRESETS = {
|
|
24
|
+
READ_ONLY: [
|
|
25
|
+
exports.SDK_METHODS.WORKFLOWS_READ,
|
|
26
|
+
exports.SDK_METHODS.CONNECTORS_READ,
|
|
27
|
+
exports.SDK_METHODS.INTEGRATIONS_READ,
|
|
28
|
+
exports.SDK_METHODS.USERS_READ,
|
|
29
|
+
exports.SDK_METHODS.RECIPES_READ,
|
|
30
|
+
],
|
|
31
|
+
FULL_ACCESS: Object.values(exports.SDK_METHODS),
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=permissions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"permissions.js","sourceRoot":"","sources":["../../../src/types/permissions.ts"],"names":[],"mappings":";;;AAQA;;GAEG;AACU,QAAA,WAAW,GAAG;IACzB,cAAc,EAAE,gBAAgB;IAChC,eAAe,EAAE,iBAAiB;IAClC,eAAe,EAAE,iBAAiB;IAClC,gBAAgB,EAAE,kBAAkB;IACpC,iBAAiB,EAAE,mBAAmB;IACtC,kBAAkB,EAAE,oBAAoB;IACxC,UAAU,EAAE,YAAY;IACxB,WAAW,EAAE,aAAa;IAC1B,QAAQ,EAAE,UAAU;IACpB,SAAS,EAAE,WAAW;IACtB,YAAY,EAAE,cAAc;CACpB,CAAC;AAEX;;GAEG;AACU,QAAA,kBAAkB,GAAG;IAChC,SAAS,EAAE;QACT,mBAAW,CAAC,cAAc;QAC1B,mBAAW,CAAC,eAAe;QAC3B,mBAAW,CAAC,iBAAiB;QAC7B,mBAAW,CAAC,UAAU;QACtB,mBAAW,CAAC,YAAY;KACzB;IACD,WAAW,EAAE,MAAM,CAAC,MAAM,CAAC,mBAAW,CAAC;CAC/B,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Workflow-related types
|
|
3
|
+
*/
|
|
4
|
+
export interface Workflow {
|
|
5
|
+
id: string;
|
|
6
|
+
name: string;
|
|
7
|
+
status: string;
|
|
8
|
+
[key: string]: any;
|
|
9
|
+
}
|
|
10
|
+
export interface CreateWorkflowPayload {
|
|
11
|
+
name: string;
|
|
12
|
+
status: string;
|
|
13
|
+
[key: string]: any;
|
|
14
|
+
}
|
|
15
|
+
export interface UpdateWorkflowPayload {
|
|
16
|
+
status?: string;
|
|
17
|
+
name?: string;
|
|
18
|
+
[key: string]: any;
|
|
19
|
+
}
|
|
20
|
+
export interface WorkflowUsage {
|
|
21
|
+
[key: string]: any;
|
|
22
|
+
}
|
|
23
|
+
export interface TriggerWorkflowPayload {
|
|
24
|
+
body?: any;
|
|
25
|
+
params?: Record<string, any>;
|
|
26
|
+
queryParams?: Record<string, any>;
|
|
27
|
+
}
|
|
28
|
+
export interface TriggerWorkflowResponse {
|
|
29
|
+
status: string;
|
|
30
|
+
message: string;
|
|
31
|
+
data: Record<string, any>;
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=workflow.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflow.d.ts","sourceRoot":"","sources":["../../../src/types/workflow.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED,MAAM,WAAW,qBAAqB;IACpC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED,MAAM,WAAW,aAAa;IAC5B,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED,MAAM,WAAW,sBAAsB;IACrC,IAAI,CAAC,EAAE,GAAG,CAAC;IACX,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC7B,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CACnC;AAED,MAAM,WAAW,uBAAuB;IACtC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC3B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflow.js","sourceRoot":"","sources":["../../../src/types/workflow.ts"],"names":[],"mappings":";AAAA;;GAEG"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ListOptions } from '../types';
|
|
2
|
+
export declare function useIntegrations(options?: ListOptions & {
|
|
3
|
+
type?: 'trigger' | 'action';
|
|
4
|
+
}): {
|
|
5
|
+
integrations: any;
|
|
6
|
+
loading: any;
|
|
7
|
+
error: any;
|
|
8
|
+
pagination: any;
|
|
9
|
+
getIntegration: any;
|
|
10
|
+
getConnections: any;
|
|
11
|
+
refresh: any;
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=useIntegrations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useIntegrations.d.ts","sourceRoot":"","sources":["../../src/react/useIntegrations.ts"],"names":[],"mappings":"AAEA,OAAO,EAA2B,WAAW,EAAqB,MAAM,UAAU,CAAC;AAEnF,wBAAgB,eAAe,CAAC,OAAO,GAAE,WAAW,GAAG;IAAE,IAAI,CAAC,EAAE,SAAS,GAAG,QAAQ,CAAA;CAAO;;;;;;;;EAsE1F"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useIntegrations = useIntegrations;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const LangslideProvider_1 = require("./LangslideProvider");
|
|
6
|
+
function useIntegrations(options = {}) {
|
|
7
|
+
const sdk = (0, LangslideProvider_1.useLangslide)();
|
|
8
|
+
const [integrations, setIntegrations] = (0, react_1.useState)([]);
|
|
9
|
+
const [loading, setLoading] = (0, react_1.useState)(true);
|
|
10
|
+
const [error, setError] = (0, react_1.useState)(null);
|
|
11
|
+
const [pagination, setPagination] = (0, react_1.useState)({
|
|
12
|
+
total: 0,
|
|
13
|
+
page: 1,
|
|
14
|
+
limit: 10,
|
|
15
|
+
totalPages: 0,
|
|
16
|
+
});
|
|
17
|
+
const loadIntegrations = (0, react_1.useCallback)(async () => {
|
|
18
|
+
try {
|
|
19
|
+
setLoading(true);
|
|
20
|
+
setError(null);
|
|
21
|
+
const result = await sdk.integrations.list(options);
|
|
22
|
+
setIntegrations(result.items);
|
|
23
|
+
setPagination({
|
|
24
|
+
total: result.total,
|
|
25
|
+
page: result.page,
|
|
26
|
+
limit: result.limit,
|
|
27
|
+
totalPages: result.totalPages,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
catch (err) {
|
|
31
|
+
setError(err.message);
|
|
32
|
+
}
|
|
33
|
+
finally {
|
|
34
|
+
setLoading(false);
|
|
35
|
+
}
|
|
36
|
+
}, [sdk, JSON.stringify(options)]);
|
|
37
|
+
(0, react_1.useEffect)(() => {
|
|
38
|
+
loadIntegrations();
|
|
39
|
+
}, [loadIntegrations]);
|
|
40
|
+
const getIntegration = (0, react_1.useCallback)(async (name) => {
|
|
41
|
+
try {
|
|
42
|
+
setError(null);
|
|
43
|
+
return await sdk.integrations.get(name);
|
|
44
|
+
}
|
|
45
|
+
catch (err) {
|
|
46
|
+
setError(err.message);
|
|
47
|
+
throw err;
|
|
48
|
+
}
|
|
49
|
+
}, [sdk]);
|
|
50
|
+
const getConnections = (0, react_1.useCallback)(async (integrationName) => {
|
|
51
|
+
try {
|
|
52
|
+
setError(null);
|
|
53
|
+
return await sdk.integrations.getConnections(integrationName);
|
|
54
|
+
}
|
|
55
|
+
catch (err) {
|
|
56
|
+
setError(err.message);
|
|
57
|
+
throw err;
|
|
58
|
+
}
|
|
59
|
+
}, [sdk]);
|
|
60
|
+
return {
|
|
61
|
+
integrations,
|
|
62
|
+
loading,
|
|
63
|
+
error,
|
|
64
|
+
pagination,
|
|
65
|
+
getIntegration,
|
|
66
|
+
getConnections,
|
|
67
|
+
refresh: loadIntegrations,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=useIntegrations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useIntegrations.js","sourceRoot":"","sources":["../../src/react/useIntegrations.ts"],"names":[],"mappings":";;AAIA,0CAsEC;AA1ED,iCAAyD;AACzD,2DAAmD;AAGnD,SAAgB,eAAe,CAAC,UAAyD,EAAE;IACzF,MAAM,GAAG,GAAG,IAAA,gCAAY,GAAE,CAAC;IAC3B,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,IAAA,gBAAQ,EAAgB,EAAE,CAAC,CAAC;IACpE,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,IAAA,gBAAQ,EAAC,IAAI,CAAC,CAAC;IAC7C,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,IAAA,gBAAQ,EAAgB,IAAI,CAAC,CAAC;IACxD,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,IAAA,gBAAQ,EAAgD;QAC1F,KAAK,EAAE,CAAC;QACR,IAAI,EAAE,CAAC;QACP,KAAK,EAAE,EAAE;QACT,UAAU,EAAE,CAAC;KACd,CAAC,CAAC;IAEH,MAAM,gBAAgB,GAAG,IAAA,mBAAW,EAAC,KAAK,IAAI,EAAE;QAC9C,IAAI,CAAC;YACH,UAAU,CAAC,IAAI,CAAC,CAAC;YACjB,QAAQ,CAAC,IAAI,CAAC,CAAC;YACf,MAAM,MAAM,GAAG,MAAM,GAAG,CAAC,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YACpD,eAAe,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YAC9B,aAAa,CAAC;gBACZ,KAAK,EAAE,MAAM,CAAC,KAAK;gBACnB,IAAI,EAAE,MAAM,CAAC,IAAI;gBACjB,KAAK,EAAE,MAAM,CAAC,KAAK;gBACnB,UAAU,EAAE,MAAM,CAAC,UAAU;aAC9B,CAAC,CAAC;QAC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AACJ,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ListOptions } from '../types';
|
|
2
|
+
export declare function useWorkflows(options?: ListOptions): {
|
|
3
|
+
workflows: any;
|
|
4
|
+
loading: any;
|
|
5
|
+
error: any;
|
|
6
|
+
pagination: any;
|
|
7
|
+
createWorkflow: any;
|
|
8
|
+
updateWorkflow: any;
|
|
9
|
+
deleteWorkflow: any;
|
|
10
|
+
triggerWorkflow: any;
|
|
11
|
+
getWorkflow: any;
|
|
12
|
+
refresh: any;
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=useWorkflows.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useWorkflows.d.ts","sourceRoot":"","sources":["../../src/react/useWorkflows.ts"],"names":[],"mappings":"AAEA,OAAO,EAA0D,WAAW,EAA6C,MAAM,UAAU,CAAC;AAE1I,wBAAgB,YAAY,CAAC,OAAO,GAAE,WAAgB;;;;;;;;;;;EAqHrD"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useWorkflows = useWorkflows;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const LangslideProvider_1 = require("./LangslideProvider");
|
|
6
|
+
function useWorkflows(options = {}) {
|
|
7
|
+
const sdk = (0, LangslideProvider_1.useLangslide)();
|
|
8
|
+
const [workflows, setWorkflows] = (0, react_1.useState)([]);
|
|
9
|
+
const [loading, setLoading] = (0, react_1.useState)(true);
|
|
10
|
+
const [error, setError] = (0, react_1.useState)(null);
|
|
11
|
+
const [pagination, setPagination] = (0, react_1.useState)({
|
|
12
|
+
total: 0,
|
|
13
|
+
page: 1,
|
|
14
|
+
limit: 10,
|
|
15
|
+
totalPages: 0,
|
|
16
|
+
});
|
|
17
|
+
const loadWorkflows = (0, react_1.useCallback)(async () => {
|
|
18
|
+
try {
|
|
19
|
+
setLoading(true);
|
|
20
|
+
setError(null);
|
|
21
|
+
const result = await sdk.workflows.list(options);
|
|
22
|
+
setWorkflows(result.items);
|
|
23
|
+
setPagination({
|
|
24
|
+
total: result.total,
|
|
25
|
+
page: result.page,
|
|
26
|
+
limit: result.limit,
|
|
27
|
+
totalPages: result.totalPages,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
catch (err) {
|
|
31
|
+
setError(err.message);
|
|
32
|
+
}
|
|
33
|
+
finally {
|
|
34
|
+
setLoading(false);
|
|
35
|
+
}
|
|
36
|
+
}, [sdk, JSON.stringify(options)]);
|
|
37
|
+
(0, react_1.useEffect)(() => {
|
|
38
|
+
loadWorkflows();
|
|
39
|
+
}, [loadWorkflows]);
|
|
40
|
+
const createWorkflow = (0, react_1.useCallback)(async (payload) => {
|
|
41
|
+
try {
|
|
42
|
+
setError(null);
|
|
43
|
+
const workflow = await sdk.workflows.create(payload);
|
|
44
|
+
await loadWorkflows();
|
|
45
|
+
return workflow;
|
|
46
|
+
}
|
|
47
|
+
catch (err) {
|
|
48
|
+
setError(err.message);
|
|
49
|
+
throw err;
|
|
50
|
+
}
|
|
51
|
+
}, [sdk, loadWorkflows]);
|
|
52
|
+
const updateWorkflow = (0, react_1.useCallback)(async (id, payload) => {
|
|
53
|
+
try {
|
|
54
|
+
setError(null);
|
|
55
|
+
const workflow = await sdk.workflows.update(id, payload);
|
|
56
|
+
await loadWorkflows();
|
|
57
|
+
return workflow;
|
|
58
|
+
}
|
|
59
|
+
catch (err) {
|
|
60
|
+
setError(err.message);
|
|
61
|
+
throw err;
|
|
62
|
+
}
|
|
63
|
+
}, [sdk, loadWorkflows]);
|
|
64
|
+
const deleteWorkflow = (0, react_1.useCallback)(async (id) => {
|
|
65
|
+
try {
|
|
66
|
+
setError(null);
|
|
67
|
+
await sdk.workflows.delete(id);
|
|
68
|
+
await loadWorkflows();
|
|
69
|
+
}
|
|
70
|
+
catch (err) {
|
|
71
|
+
setError(err.message);
|
|
72
|
+
throw err;
|
|
73
|
+
}
|
|
74
|
+
}, [sdk, loadWorkflows]);
|
|
75
|
+
const triggerWorkflow = (0, react_1.useCallback)(async (workflowId, payload) => {
|
|
76
|
+
try {
|
|
77
|
+
setError(null);
|
|
78
|
+
await sdk.workflows.trigger(workflowId, payload);
|
|
79
|
+
}
|
|
80
|
+
catch (err) {
|
|
81
|
+
setError(err.message);
|
|
82
|
+
throw err;
|
|
83
|
+
}
|
|
84
|
+
}, [sdk]);
|
|
85
|
+
const getWorkflow = (0, react_1.useCallback)(async (id) => {
|
|
86
|
+
try {
|
|
87
|
+
setError(null);
|
|
88
|
+
return await sdk.workflows.get(id);
|
|
89
|
+
}
|
|
90
|
+
catch (err) {
|
|
91
|
+
setError(err.message);
|
|
92
|
+
throw err;
|
|
93
|
+
}
|
|
94
|
+
}, [sdk]);
|
|
95
|
+
return {
|
|
96
|
+
workflows,
|
|
97
|
+
loading,
|
|
98
|
+
error,
|
|
99
|
+
pagination,
|
|
100
|
+
createWorkflow,
|
|
101
|
+
updateWorkflow,
|
|
102
|
+
deleteWorkflow,
|
|
103
|
+
triggerWorkflow,
|
|
104
|
+
getWorkflow,
|
|
105
|
+
refresh: loadWorkflows,
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
//# sourceMappingURL=useWorkflows.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useWorkflows.js","sourceRoot":"","sources":["../../src/react/useWorkflows.ts"],"names":[],"mappings":";;AAIA,oCAqHC;AAzHD,iCAAyD;AACzD,2DAAmD;AAGnD,SAAgB,YAAY,CAAC,UAAuB,EAAE;IACpD,MAAM,GAAG,GAAG,IAAA,gCAAY,GAAE,CAAC;IAC3B,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,IAAA,gBAAQ,EAAa,EAAE,CAAC,CAAC;IAC3D,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,IAAA,gBAAQ,EAAC,IAAI,CAAC,CAAC;IAC7C,MAAM,CAA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A,mBAAW,EACjC,KAAK,EAAE,UAAkB,EAAE,OAAgC,EAAiB,EAAE;QAC5E,IAAI,CAAC;YACH,QAAQ,CAAC,IAAI,CAAC,CAAC;YACf,MAAM,GAAG,CAAC,SAAS,CAAC,OAAO,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;QACnD,CAAC;QAAC,OAAO,GAAQ,EAAE,CAAC;YAClB,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;YACtB,MAAM,GAAG,CAAC;QACZ,CAAC;IACH,CAAC,EACD,CAAC,GAAG,CAAC,CACN,CAAC;IAEF,MAAM,WAAW,GAAG,IAAA,mBAAW,EAC7B,KAAK,EAAE,EAAU,EAAqB,EAAE;QACtC,IAAI,CAAC;YACH,QAAQ,CAAC,IAAI,CAAC,CAAC;YACf,OAAO,MAAM,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QACrC,CAAC;QAAC,OAAO,GAAQ,EAAE,CAAC;YAClB,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;YACtB,MAAM,GAAG,CAAC;QACZ,CAAC;IACH,CAAC,EACD,CAAC,GAAG,CAAC,CACN,CAAC;IAEF,OAAO;QACL,SAAS;QACT,OAAO;QACP,KAAK;QACL,UAAU;QACV,cAAc;QACd,cAAc;QACd,cAAc;QACd,eAAe;QACf,WAAW;QACX,OAAO,EAAE,aAAa;KACvB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { IAPIKeyPermissions } from '../types/permissions';
|
|
2
|
+
/**
|
|
3
|
+
* Check if user has required permission before making API call
|
|
4
|
+
* @throws {LangslidePermissionError} If permission is missing
|
|
5
|
+
*/
|
|
6
|
+
export declare function requirePermission(permissions: IAPIKeyPermissions | undefined, requiredPermission: string): void;
|
|
7
|
+
/**
|
|
8
|
+
* Check if user has access to a specific connector
|
|
9
|
+
* Connector names are normalized to lowercase for consistent matching
|
|
10
|
+
* @throws {LangslidePermissionError} If connector access is denied
|
|
11
|
+
*/
|
|
12
|
+
export declare function requireConnectorAccess(permissions: IAPIKeyPermissions | undefined, connectorName: string): void;
|
|
13
|
+
//# sourceMappingURL=permission-guard.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"permission-guard.d.ts","sourceRoot":"","sources":["../../../src/utils/permission-guard.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAG1D;;;GAGG;AACH,wBAAgB,iBAAiB,CAC/B,WAAW,EAAE,kBAAkB,GAAG,SAAS,EAC3C,kBAAkB,EAAE,MAAM,GACzB,IAAI,CAON;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CACpC,WAAW,EAAE,kBAAkB,GAAG,SAAS,EAC3C,aAAa,EAAE,MAAM,GACpB,IAAI,CAQN"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.requirePermission = requirePermission;
|
|
4
|
+
exports.requireConnectorAccess = requireConnectorAccess;
|
|
5
|
+
const errors_1 = require("../errors");
|
|
6
|
+
const permissions_1 = require("./permissions");
|
|
7
|
+
/**
|
|
8
|
+
* Check if user has required permission before making API call
|
|
9
|
+
* @throws {LangslidePermissionError} If permission is missing
|
|
10
|
+
*/
|
|
11
|
+
function requirePermission(permissions, requiredPermission) {
|
|
12
|
+
if (!permissions_1.PermissionChecker.hasPermission(permissions, requiredPermission)) {
|
|
13
|
+
throw new errors_1.LangslidePermissionError(`Insufficient permissions. Required: ${requiredPermission}`, requiredPermission);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Check if user has access to a specific connector
|
|
18
|
+
* Connector names are normalized to lowercase for consistent matching
|
|
19
|
+
* @throws {LangslidePermissionError} If connector access is denied
|
|
20
|
+
*/
|
|
21
|
+
function requireConnectorAccess(permissions, connectorName) {
|
|
22
|
+
// Normalize connector name to lowercase before checking
|
|
23
|
+
const normalizedName = connectorName.toLowerCase();
|
|
24
|
+
if (!permissions_1.PermissionChecker.hasConnectorAccess(permissions, normalizedName)) {
|
|
25
|
+
throw new errors_1.LangslidePermissionError(`Insufficient permissions. Access to connector '${connectorName}' is required.`);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=permission-guard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"permission-guard.js","sourceRoot":"","sources":["../../../src/utils/permission-guard.ts"],"names":[],"mappings":";;AAQA,8CAUC;AAOD,wDAWC;AApCD,sCAAqD;AAErD,+CAAkD;AAElD;;;GAGG;AACH,SAAgB,iBAAiB,CAC/B,WAA2C,EAC3C,kBAA0B;IAE1B,IAAI,CAAC,+BAAiB,CAAC,aAAa,CAAC,WAAW,EAAE,kBAAkB,CAAC,EAAE,CAAC;QACtE,MAAM,IAAI,iCAAwB,CAChC,uCAAuC,kBAAkB,EAAE,EAC3D,kBAAkB,CACnB,CAAC;IACJ,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,SAAgB,sBAAsB,CACpC,WAA2C,EAC3C,aAAqB;IAErB,wDAAwD;IACxD,MAAM,cAAc,GAAG,aAAa,CAAC,WAAW,EAAE,CAAC;IACnD,IAAI,CAAC,+BAAiB,CAAC,kBAAkB,CAAC,WAAW,EAAE,cAAc,CAAC,EAAE,CAAC;QACvE,MAAM,IAAI,iCAAwB,CAChC,kDAAkD,aAAa,gBAAgB,CAChF,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { IAPIKeyPermissions } from '../types/permissions';
|
|
2
|
+
/**
|
|
3
|
+
* Permission checker utility class
|
|
4
|
+
*/
|
|
5
|
+
export declare class PermissionChecker {
|
|
6
|
+
/**
|
|
7
|
+
* Check if a required permission exists in the permissions array
|
|
8
|
+
*/
|
|
9
|
+
static hasPermission(permissions: IAPIKeyPermissions | undefined, requiredPermission: string): boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Check if user has access to a specific connector
|
|
12
|
+
* Connector names are normalized to lowercase for consistent matching
|
|
13
|
+
*/
|
|
14
|
+
static hasConnectorAccess(permissions: IAPIKeyPermissions | undefined, connectorName: string): boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Get all available permissions
|
|
17
|
+
*/
|
|
18
|
+
static getAllPermissions(): string[];
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=permissions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"permissions.d.ts","sourceRoot":"","sources":["../../../src/utils/permissions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAe,MAAM,sBAAsB,CAAC;AAEvE;;GAEG;AACH,qBAAa,iBAAiB;IAC5B;;OAEG;WACW,aAAa,CACzB,WAAW,EAAE,kBAAkB,GAAG,SAAS,EAC3C,kBAAkB,EAAE,MAAM,GACzB,OAAO;IAeV;;;OAGG;WACW,kBAAkB,CAC9B,WAAW,EAAE,kBAAkB,GAAG,SAAS,EAC3C,aAAa,EAAE,MAAM,GACpB,OAAO;IAmBV;;OAEG;WACW,iBAAiB,IAAI,MAAM,EAAE;CAG5C"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PermissionChecker = void 0;
|
|
4
|
+
const permissions_1 = require("../types/permissions");
|
|
5
|
+
/**
|
|
6
|
+
* Permission checker utility class
|
|
7
|
+
*/
|
|
8
|
+
class PermissionChecker {
|
|
9
|
+
/**
|
|
10
|
+
* Check if a required permission exists in the permissions array
|
|
11
|
+
*/
|
|
12
|
+
static hasPermission(permissions, requiredPermission) {
|
|
13
|
+
// If no permissions provided (JWT user), allow access
|
|
14
|
+
if (!permissions) {
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
// Check for wildcard permission
|
|
18
|
+
if (permissions.sdk_methods.includes('*')) {
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
21
|
+
// Check if the required permission is in the SDK methods
|
|
22
|
+
return permissions.sdk_methods.includes(requiredPermission);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Check if user has access to a specific connector
|
|
26
|
+
* Connector names are normalized to lowercase for consistent matching
|
|
27
|
+
*/
|
|
28
|
+
static hasConnectorAccess(permissions, connectorName) {
|
|
29
|
+
// If no permissions provided (JWT user), allow access
|
|
30
|
+
if (!permissions) {
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
// Normalize connector name to lowercase for consistent matching
|
|
34
|
+
const normalizedConnectorName = connectorName.toLowerCase();
|
|
35
|
+
// Check if user has access to all connectors (*) or specific connector
|
|
36
|
+
// Also normalize permission connector names for comparison
|
|
37
|
+
return (permissions.connectors.includes('*') ||
|
|
38
|
+
permissions.connectors.some((perm) => perm.toLowerCase() === normalizedConnectorName));
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Get all available permissions
|
|
42
|
+
*/
|
|
43
|
+
static getAllPermissions() {
|
|
44
|
+
return Object.values(permissions_1.SDK_METHODS);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
exports.PermissionChecker = PermissionChecker;
|
|
48
|
+
//# sourceMappingURL=permissions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"permissions.js","sourceRoot":"","sources":["../../../src/utils/permissions.ts"],"names":[],"mappings":";;;AAAA,sDAAuE;AAEvE;;GAEG;AACH,MAAa,iBAAiB;IAC5B;;OAEG;IACI,MAAM,CAAC,aAAa,CACzB,WAA2C,EAC3C,kBAA0B;QAE1B,sDAAsD;QACtD,IAAI,CAAC,WAAW,EAAE,CAAC;YACjB,OAAO,IAAI,CAAC;QACd,CAAC;QAED,gCAAgC;QAChC,IAAI,WAAW,CAAC,WAAW,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;YAC1C,OAAO,IAAI,CAAC;QACd,CAAC;QAED,yDAAyD;QACzD,OAAO,WAAW,CAAC,WAAW,CAAC,QAAQ,CAAC,kBAAkB,CAAC,CAAC;IAC9D,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,kBAAkB,CAC9B,WAA2C,EAC3C,aAAqB;QAErB,sDAAsD;QACtD,IAAI,CAAC,WAAW,EAAE,CAAC;YACjB,OAAO,IAAI,CAAC;QACd,CAAC;QAED,gEAAgE;QAChE,MAAM,uBAAuB,GAAG,aAAa,CAAC,WAAW,EAAE,CAAC;QAE5D,uEAAuE;QACvE,2DAA2D;QAC3D,OAAO,CACL,WAAW,CAAC,UAAU,CAAC,QAAQ,CAAC,GAAG,CAAC;YACpC,WAAW,CAAC,UAAU,CAAC,IAAI,CACzB,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,WAAW,EAAE,KAAK,uBAAuB,CACzD,CACF,CAAC;IACJ,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,iBAAiB;QAC7B,OAAO,MAAM,CAAC,MAAM,CAAC,yBAAW,CAAC,CAAC;IACpC,CAAC;CACF;AAtDD,8CAsDC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { AxiosInstance } from 'axios';
|
|
2
|
+
import { LangslideSDKConfigResolved } from '../config';
|
|
3
|
+
/**
|
|
4
|
+
* Creates an Axios instance configured for the SDK
|
|
5
|
+
*/
|
|
6
|
+
export declare function createRequestClient(config: LangslideSDKConfigResolved): AxiosInstance;
|
|
7
|
+
//# sourceMappingURL=request.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../../../src/utils/request.ts"],"names":[],"mappings":"AAAA,OAAc,EAAE,aAAa,EAAkC,MAAM,OAAO,CAAC;AAE7E,OAAO,EAAE,0BAA0B,EAAE,MAAM,WAAW,CAAC;AAEvD;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,0BAA0B,GAAG,aAAa,CA4CrF"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.createRequestClient = createRequestClient;
|
|
7
|
+
const axios_1 = __importDefault(require("axios"));
|
|
8
|
+
const errors_1 = require("../errors");
|
|
9
|
+
/**
|
|
10
|
+
* Creates an Axios instance configured for the SDK
|
|
11
|
+
*/
|
|
12
|
+
function createRequestClient(config) {
|
|
13
|
+
const client = axios_1.default.create({
|
|
14
|
+
baseURL: config.baseUrl,
|
|
15
|
+
timeout: config.timeout,
|
|
16
|
+
headers: {
|
|
17
|
+
'Content-Type': 'application/json',
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
// Request interceptor: inject API key
|
|
21
|
+
client.interceptors.request.use((requestConfig) => {
|
|
22
|
+
var _a;
|
|
23
|
+
if (config.apiKey) {
|
|
24
|
+
requestConfig.headers['X-API-Key'] = config.apiKey;
|
|
25
|
+
}
|
|
26
|
+
if (config.enableLogging) {
|
|
27
|
+
console.log(`[LangslideSDK] ${(_a = requestConfig.method) === null || _a === void 0 ? void 0 : _a.toUpperCase()} ${requestConfig.url}`);
|
|
28
|
+
}
|
|
29
|
+
return requestConfig;
|
|
30
|
+
}, (error) => {
|
|
31
|
+
return Promise.reject((0, errors_1.transformError)(error));
|
|
32
|
+
});
|
|
33
|
+
// Response interceptor: transform errors
|
|
34
|
+
client.interceptors.response.use((response) => {
|
|
35
|
+
if (config.enableLogging) {
|
|
36
|
+
console.log(`[LangslideSDK] Response:`, response.status, response.config.url);
|
|
37
|
+
}
|
|
38
|
+
return response;
|
|
39
|
+
}, (error) => {
|
|
40
|
+
var _a;
|
|
41
|
+
if (config.enableLogging) {
|
|
42
|
+
console.error(`[LangslideSDK] Error:`, error.message, (_a = error.config) === null || _a === void 0 ? void 0 : _a.url);
|
|
43
|
+
}
|
|
44
|
+
return Promise.reject((0, errors_1.transformError)(error));
|
|
45
|
+
});
|
|
46
|
+
return client;
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=request.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request.js","sourceRoot":"","sources":["../../../src/utils/request.ts"],"names":[],"mappings":";;;;;AAOA,kDA4CC;AAnDD,kDAA6E;AAC7E,sCAA2D;AAG3D;;GAEG;AACH,SAAgB,mBAAmB,CAAC,MAAkC;IACpE,MAAM,MAAM,GAAG,eAAK,CAAC,MAAM,CAAC;QAC1B,OAAO,EAAE,MAAM,CAAC,OAAO;QACvB,OAAO,EAAE,MAAM,CAAC,OAAO;QACvB,OAAO,EAAE;YACP,cAAc,EAAE,kBAAkB;SACnC;KACF,CAAC,CAAC;IAEH,sCAAsC;IACtC,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,GAAG,CAC7B,CAAC,aAAa,EAAE,EAAE;;QAChB,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;YAClB,aAAa,CAAC,OAAO,CAAC,WAAW,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC;QACrD,CAAC;QAED,IAAI,MAAM,CAAC,aAAa,EAAE,CAAC;YACzB,OAAO,CAAC,GAAG,CAAC,kBAAkB,MAAA,aAAa,CAAC,MAAM,0CAAE,WAAW,EAAE,IAAI,aAAa,CAAC,GAAG,EAAE,CAAC,CAAC;QAC5F,CAAC;QAED,OAAO,aAAa,CAAC;IACvB,CAAC,EACD,CAAC,KAAK,EAAE,EAAE;QACR,OAAO,OAAO,CAAC,MAAM,CAAC,IAAA,uBAAc,EAAC,KAAK,CAAC,CAAC,CAAC;IAC/C,CAAC,CACF,CAAC;IAEF,yCAAyC;IACzC,MAAM,CAAC,YAAY,CAAC,QAAQ,CAAC,GAAG,CAC9B,CAAC,QAAQ,EAAE,EAAE;QACX,IAAI,MAAM,CAAC,aAAa,EAAE,CAAC;YACzB,OAAO,CAAC,GAAG,CAAC,0BAA0B,EAAE,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAChF,CAAC;QACD,OAAO,QAAQ,CAAC;IAClB,CAAC,EACD,CAAC,KAAiB,EAAE,EAAE;;QACpB,IAAI,MAAM,CAAC,aAAa,EAAE,CAAC;YACzB,OAAO,CAAC,KAAK,CAAC,uBAAuB,EAAE,KAAK,CAAC,OAAO,EAAE,MAAA,KAAK,CAAC,MAAM,0CAAE,GAAG,CAAC,CAAC;QAC3E,CAAC;QACD,OAAO,OAAO,CAAC,MAAM,CAAC,IAAA,uBAAc,EAAC,KAAK,CAAC,CAAC,CAAC;IAC/C,CAAC,CACF,CAAC;IAEF,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/types/auth.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../src/types/auth.ts"],"names":[],"mappings":";AAAA;;;GAGG;AAEH,+EAA+E"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Common types used across the SDK
|
|
3
|
+
*/
|
|
4
|
+
export interface APIResponse<T = any> {
|
|
5
|
+
success: boolean;
|
|
6
|
+
message?: string;
|
|
7
|
+
data: T;
|
|
8
|
+
error?: string;
|
|
9
|
+
}
|
|
10
|
+
export interface PaginatedResponse<T = any> {
|
|
11
|
+
items: T[];
|
|
12
|
+
total: number;
|
|
13
|
+
page: number;
|
|
14
|
+
limit: number;
|
|
15
|
+
totalPages: number;
|
|
16
|
+
}
|
|
17
|
+
export interface ListOptions {
|
|
18
|
+
page?: number;
|
|
19
|
+
limit?: number;
|
|
20
|
+
status?: string;
|
|
21
|
+
search?: string;
|
|
22
|
+
sortBy?: string;
|
|
23
|
+
sortOrder?: 'asc' | 'desc';
|
|
24
|
+
createdAfter?: string | Date;
|
|
25
|
+
createdBefore?: string | Date;
|
|
26
|
+
tags?: string[];
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=common.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../src/types/common.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,WAAW,CAAC,CAAC,GAAG,GAAG;IAClC,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,CAAC,CAAC;IACR,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,iBAAiB,CAAC,CAAC,GAAG,GAAG;IACxC,KAAK,EAAE,CAAC,EAAE,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;IAC3B,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;CACjB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../src/types/common.ts"],"names":[],"mappings":";AAAA;;GAEG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAE9B,cAAc,eAAe,CAAC"}
|