@membranehq/sdk 0.19.0 → 0.21.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/dist/bundle.d.ts +15 -10
- package/dist/bundle.js +14 -2
- package/dist/bundle.js.map +1 -1
- package/dist/config.d.mts +38 -0
- package/dist/config.d.ts +38 -0
- package/dist/config.js +215 -0
- package/dist/config.js.map +1 -0
- package/dist/config.mjs +187 -0
- package/dist/config.mjs.map +1 -0
- package/dist/dts/accessors/connections-accessors.d.ts +1 -1
- package/dist/dts/accessors/integrations-accessors.d.ts +1 -1
- package/dist/dts/agent/session.d.ts +9 -0
- package/dist/dts/functions/base.d.ts +1 -0
- package/dist/dts/functions/function-types/index.d.ts +2 -2
- package/dist/dts/functions/function-types/rest-api-mapping.d.ts +6 -6
- package/dist/dts/index.node.d.ts +0 -1
- package/dist/dts/orgs/types.d.ts +1 -0
- package/dist/dts/ui.d.ts +5 -0
- package/dist/dts/workspace-elements/api/action-run-log-records-api.d.ts +2 -2
- package/dist/dts/workspace-elements/api/connections-api.d.ts +3 -3
- package/dist/dts/workspace-elements/api/data-link-table-instances-api.d.ts +1 -1
- package/dist/dts/workspace-elements/api/data-sources-api.d.ts +2 -2
- package/dist/dts/workspace-elements/api/external-api-logs-api.d.ts +1 -1
- package/dist/dts/workspace-elements/api/external-event-log-records-api.d.ts +1 -1
- package/dist/dts/workspace-elements/api/external-event-pulls-api.d.ts +1 -1
- package/dist/dts/workspace-elements/api/external-event-subscriptions-api.d.ts +1 -1
- package/dist/dts/workspace-elements/api/field-mappings-api.d.ts +2 -2
- package/dist/dts/workspace-elements/api/flow-runs-api.d.ts +2 -2
- package/dist/dts/workspace-elements/api/flows-api.d.ts +2 -2
- package/dist/dts/workspace-elements/api/incoming-webhooks-api.d.ts +1 -1
- package/dist/dts/workspace-elements/api/integrations-api.d.ts +1 -1
- package/dist/dts/workspace-elements/base/connection-requests/index.d.ts +8 -1
- package/dist/dts/workspace-elements/base/connections/index.d.ts +1 -1
- package/dist/dts/workspaces/types.d.ts +2 -0
- package/dist/index.browser.d.mts +58 -33
- package/dist/index.browser.d.ts +58 -33
- package/dist/index.browser.js +62 -6
- package/dist/index.browser.js.map +1 -1
- package/dist/index.browser.mjs +59 -7
- package/dist/index.browser.mjs.map +1 -1
- package/dist/index.node.d.mts +59 -68
- package/dist/index.node.d.ts +59 -68
- package/dist/index.node.js +62 -196
- package/dist/index.node.js.map +1 -1
- package/dist/index.node.mjs +59 -189
- package/dist/index.node.mjs.map +1 -1
- package/package.json +12 -1
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
declare const CONFIG_FILE_NAME = "membrane.config.yml";
|
|
4
|
+
declare const membraneConfigSchema: z.ZodObject<{
|
|
5
|
+
workspaceKey: z.ZodString;
|
|
6
|
+
workspaceSecret: z.ZodString;
|
|
7
|
+
apiUri: z.ZodOptional<z.ZodString>;
|
|
8
|
+
consoleUri: z.ZodOptional<z.ZodString>;
|
|
9
|
+
testCustomerId: z.ZodOptional<z.ZodString>;
|
|
10
|
+
accessToken: z.ZodOptional<z.ZodString>;
|
|
11
|
+
}, z.core.$strip>;
|
|
12
|
+
type MembraneConfig = z.infer<typeof membraneConfigSchema>;
|
|
13
|
+
type PartialMembraneConfig = Partial<MembraneConfig>;
|
|
14
|
+
interface LoadConfigOptions {
|
|
15
|
+
validate?: boolean;
|
|
16
|
+
useCache?: boolean;
|
|
17
|
+
}
|
|
18
|
+
declare class MembraneConfigLoader {
|
|
19
|
+
private cachedConfig;
|
|
20
|
+
private cwd;
|
|
21
|
+
constructor(cwd?: string);
|
|
22
|
+
loadConfig(options?: LoadConfigOptions): PartialMembraneConfig;
|
|
23
|
+
hasValidConfig(): boolean;
|
|
24
|
+
hasWorkspaceCredentials(): boolean;
|
|
25
|
+
clearCache(): void;
|
|
26
|
+
updateConfig(newConfig: PartialMembraneConfig): PartialMembraneConfig;
|
|
27
|
+
saveToFile(config: PartialMembraneConfig): boolean;
|
|
28
|
+
getCwd(): string;
|
|
29
|
+
setCwd(newCwd: string): void;
|
|
30
|
+
private loadFromFile;
|
|
31
|
+
private loadFromEnv;
|
|
32
|
+
}
|
|
33
|
+
declare function getDefaultMembraneConfigLoader(): MembraneConfigLoader;
|
|
34
|
+
declare function loadMembraneConfig(cwd?: string, options?: LoadConfigOptions): PartialMembraneConfig;
|
|
35
|
+
declare function hasMembraneCredentials(cwd?: string): boolean;
|
|
36
|
+
|
|
37
|
+
export { CONFIG_FILE_NAME, MembraneConfigLoader, getDefaultMembraneConfigLoader, hasMembraneCredentials, loadMembraneConfig, membraneConfigSchema };
|
|
38
|
+
export type { LoadConfigOptions, MembraneConfig, PartialMembraneConfig };
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
declare const CONFIG_FILE_NAME = "membrane.config.yml";
|
|
4
|
+
declare const membraneConfigSchema: z.ZodObject<{
|
|
5
|
+
workspaceKey: z.ZodString;
|
|
6
|
+
workspaceSecret: z.ZodString;
|
|
7
|
+
apiUri: z.ZodOptional<z.ZodString>;
|
|
8
|
+
consoleUri: z.ZodOptional<z.ZodString>;
|
|
9
|
+
testCustomerId: z.ZodOptional<z.ZodString>;
|
|
10
|
+
accessToken: z.ZodOptional<z.ZodString>;
|
|
11
|
+
}, z.core.$strip>;
|
|
12
|
+
type MembraneConfig = z.infer<typeof membraneConfigSchema>;
|
|
13
|
+
type PartialMembraneConfig = Partial<MembraneConfig>;
|
|
14
|
+
interface LoadConfigOptions {
|
|
15
|
+
validate?: boolean;
|
|
16
|
+
useCache?: boolean;
|
|
17
|
+
}
|
|
18
|
+
declare class MembraneConfigLoader {
|
|
19
|
+
private cachedConfig;
|
|
20
|
+
private cwd;
|
|
21
|
+
constructor(cwd?: string);
|
|
22
|
+
loadConfig(options?: LoadConfigOptions): PartialMembraneConfig;
|
|
23
|
+
hasValidConfig(): boolean;
|
|
24
|
+
hasWorkspaceCredentials(): boolean;
|
|
25
|
+
clearCache(): void;
|
|
26
|
+
updateConfig(newConfig: PartialMembraneConfig): PartialMembraneConfig;
|
|
27
|
+
saveToFile(config: PartialMembraneConfig): boolean;
|
|
28
|
+
getCwd(): string;
|
|
29
|
+
setCwd(newCwd: string): void;
|
|
30
|
+
private loadFromFile;
|
|
31
|
+
private loadFromEnv;
|
|
32
|
+
}
|
|
33
|
+
declare function getDefaultMembraneConfigLoader(): MembraneConfigLoader;
|
|
34
|
+
declare function loadMembraneConfig(cwd?: string, options?: LoadConfigOptions): PartialMembraneConfig;
|
|
35
|
+
declare function hasMembraneCredentials(cwd?: string): boolean;
|
|
36
|
+
|
|
37
|
+
export { CONFIG_FILE_NAME, MembraneConfigLoader, getDefaultMembraneConfigLoader, hasMembraneCredentials, loadMembraneConfig, membraneConfigSchema };
|
|
38
|
+
export type { LoadConfigOptions, MembraneConfig, PartialMembraneConfig };
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var fs = require('fs');
|
|
4
|
+
var yaml = require('js-yaml');
|
|
5
|
+
var path = require('path');
|
|
6
|
+
var zod = require('zod');
|
|
7
|
+
|
|
8
|
+
function _interopNamespaceDefault(e) {
|
|
9
|
+
var n = Object.create(null);
|
|
10
|
+
if (e) {
|
|
11
|
+
Object.keys(e).forEach(function (k) {
|
|
12
|
+
if (k !== 'default') {
|
|
13
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
14
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: function () { return e[k]; }
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
n.default = e;
|
|
22
|
+
return Object.freeze(n);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
var fs__namespace = /*#__PURE__*/_interopNamespaceDefault(fs);
|
|
26
|
+
var yaml__namespace = /*#__PURE__*/_interopNamespaceDefault(yaml);
|
|
27
|
+
var path__namespace = /*#__PURE__*/_interopNamespaceDefault(path);
|
|
28
|
+
|
|
29
|
+
const CONFIG_FILE_NAME = 'membrane.config.yml';
|
|
30
|
+
const membraneConfigSchema = zod.z.object({
|
|
31
|
+
workspaceKey: zod.z.string(),
|
|
32
|
+
workspaceSecret: zod.z.string(),
|
|
33
|
+
apiUri: zod.z.string().optional(),
|
|
34
|
+
consoleUri: zod.z.string().optional(),
|
|
35
|
+
testCustomerId: zod.z.string().optional(),
|
|
36
|
+
accessToken: zod.z.string().optional(),
|
|
37
|
+
});
|
|
38
|
+
class MembraneConfigLoader {
|
|
39
|
+
constructor(cwd = process.cwd()) {
|
|
40
|
+
this.cachedConfig = null;
|
|
41
|
+
this.cwd = cwd;
|
|
42
|
+
}
|
|
43
|
+
loadConfig(options = {}) {
|
|
44
|
+
const { validate = false, useCache = true } = options;
|
|
45
|
+
if (useCache && this.cachedConfig !== null) {
|
|
46
|
+
if (validate) {
|
|
47
|
+
const validation = membraneConfigSchema.safeParse(this.cachedConfig);
|
|
48
|
+
if (!validation.success) {
|
|
49
|
+
throw new Error(`Invalid configuration: ${validation.error.message}`);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return this.cachedConfig;
|
|
53
|
+
}
|
|
54
|
+
const fileConfig = this.loadFromFile();
|
|
55
|
+
const envConfig = this.loadFromEnv();
|
|
56
|
+
const mergedConfig = {
|
|
57
|
+
...fileConfig,
|
|
58
|
+
...envConfig,
|
|
59
|
+
};
|
|
60
|
+
this.cachedConfig = mergedConfig;
|
|
61
|
+
if (validate) {
|
|
62
|
+
const validation = membraneConfigSchema.safeParse(mergedConfig);
|
|
63
|
+
if (!validation.success) {
|
|
64
|
+
throw new Error(`Invalid configuration: ${validation.error.message}`);
|
|
65
|
+
}
|
|
66
|
+
return validation.data;
|
|
67
|
+
}
|
|
68
|
+
return mergedConfig;
|
|
69
|
+
}
|
|
70
|
+
hasValidConfig() {
|
|
71
|
+
try {
|
|
72
|
+
const config = this.loadConfig({ validate: true });
|
|
73
|
+
return Boolean(config.workspaceKey && config.workspaceSecret);
|
|
74
|
+
}
|
|
75
|
+
catch (_a) {
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
hasWorkspaceCredentials() {
|
|
80
|
+
const config = this.loadConfig();
|
|
81
|
+
return Boolean(config.workspaceKey && config.workspaceSecret);
|
|
82
|
+
}
|
|
83
|
+
clearCache() {
|
|
84
|
+
this.cachedConfig = null;
|
|
85
|
+
}
|
|
86
|
+
updateConfig(newConfig) {
|
|
87
|
+
const currentConfig = this.loadConfig({ useCache: false });
|
|
88
|
+
const mergedConfig = {
|
|
89
|
+
...currentConfig,
|
|
90
|
+
...newConfig,
|
|
91
|
+
};
|
|
92
|
+
this.saveToFile(newConfig);
|
|
93
|
+
this.cachedConfig = mergedConfig;
|
|
94
|
+
return mergedConfig;
|
|
95
|
+
}
|
|
96
|
+
saveToFile(config) {
|
|
97
|
+
const configPath = path__namespace.join(this.cwd, CONFIG_FILE_NAME);
|
|
98
|
+
const fileConfig = this.loadFromFile();
|
|
99
|
+
const newFileConfig = {
|
|
100
|
+
...fileConfig,
|
|
101
|
+
...config,
|
|
102
|
+
};
|
|
103
|
+
const envConfig = this.loadFromEnv();
|
|
104
|
+
for (const key of Object.keys(envConfig)) {
|
|
105
|
+
if (envConfig[key] === newFileConfig[key]) {
|
|
106
|
+
delete newFileConfig[key];
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
try {
|
|
110
|
+
const yamlStr = yaml__namespace.dump(newFileConfig);
|
|
111
|
+
fs__namespace.writeFileSync(configPath, yamlStr, 'utf8');
|
|
112
|
+
return true;
|
|
113
|
+
}
|
|
114
|
+
catch (_error) {
|
|
115
|
+
return false;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
getCwd() {
|
|
119
|
+
return this.cwd;
|
|
120
|
+
}
|
|
121
|
+
setCwd(newCwd) {
|
|
122
|
+
if (this.cwd !== newCwd) {
|
|
123
|
+
this.cwd = newCwd;
|
|
124
|
+
this.clearCache();
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
loadFromFile() {
|
|
128
|
+
const configPath = path__namespace.join(this.cwd, CONFIG_FILE_NAME);
|
|
129
|
+
let configFile;
|
|
130
|
+
try {
|
|
131
|
+
configFile = fs__namespace.readFileSync(configPath, 'utf8');
|
|
132
|
+
}
|
|
133
|
+
catch (_a) {
|
|
134
|
+
return {};
|
|
135
|
+
}
|
|
136
|
+
let parsedConfig;
|
|
137
|
+
try {
|
|
138
|
+
parsedConfig = yaml__namespace.load(configFile);
|
|
139
|
+
}
|
|
140
|
+
catch (yamlError) {
|
|
141
|
+
throw new Error(`Failed to parse ${CONFIG_FILE_NAME}: ${yamlError.message}`);
|
|
142
|
+
}
|
|
143
|
+
const config = {};
|
|
144
|
+
if (parsedConfig === null || parsedConfig === void 0 ? void 0 : parsedConfig.accessToken) {
|
|
145
|
+
config.accessToken = String(parsedConfig.accessToken);
|
|
146
|
+
}
|
|
147
|
+
if (parsedConfig === null || parsedConfig === void 0 ? void 0 : parsedConfig.workspaceKey) {
|
|
148
|
+
config.workspaceKey = String(parsedConfig.workspaceKey);
|
|
149
|
+
}
|
|
150
|
+
if (parsedConfig === null || parsedConfig === void 0 ? void 0 : parsedConfig.workspaceSecret) {
|
|
151
|
+
config.workspaceSecret = String(parsedConfig.workspaceSecret);
|
|
152
|
+
}
|
|
153
|
+
if (parsedConfig === null || parsedConfig === void 0 ? void 0 : parsedConfig.apiUri) {
|
|
154
|
+
config.apiUri = String(parsedConfig.apiUri);
|
|
155
|
+
}
|
|
156
|
+
if (parsedConfig === null || parsedConfig === void 0 ? void 0 : parsedConfig.consoleUri) {
|
|
157
|
+
config.consoleUri = String(parsedConfig.consoleUri);
|
|
158
|
+
}
|
|
159
|
+
if (parsedConfig === null || parsedConfig === void 0 ? void 0 : parsedConfig.testCustomerId) {
|
|
160
|
+
config.testCustomerId = String(parsedConfig.testCustomerId);
|
|
161
|
+
}
|
|
162
|
+
return config;
|
|
163
|
+
}
|
|
164
|
+
loadFromEnv() {
|
|
165
|
+
const config = {};
|
|
166
|
+
if (process.env.MEMBRANE_ACCESS_TOKEN) {
|
|
167
|
+
config.accessToken = process.env.MEMBRANE_ACCESS_TOKEN;
|
|
168
|
+
}
|
|
169
|
+
if (process.env.MEMBRANE_WORKSPACE_KEY) {
|
|
170
|
+
config.workspaceKey = process.env.MEMBRANE_WORKSPACE_KEY;
|
|
171
|
+
}
|
|
172
|
+
if (process.env.MEMBRANE_WORKSPACE_SECRET) {
|
|
173
|
+
config.workspaceSecret = process.env.MEMBRANE_WORKSPACE_SECRET;
|
|
174
|
+
}
|
|
175
|
+
if (process.env.MEMBRANE_API_URI) {
|
|
176
|
+
config.apiUri = process.env.MEMBRANE_API_URI;
|
|
177
|
+
}
|
|
178
|
+
if (process.env.MEMBRANE_CONSOLE_URI) {
|
|
179
|
+
config.consoleUri = process.env.MEMBRANE_CONSOLE_URI;
|
|
180
|
+
}
|
|
181
|
+
if (process.env.MEMBRANE_TEST_CUSTOMER_ID) {
|
|
182
|
+
config.testCustomerId = process.env.MEMBRANE_TEST_CUSTOMER_ID;
|
|
183
|
+
}
|
|
184
|
+
return config;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
let defaultLoader = null;
|
|
188
|
+
function getDefaultMembraneConfigLoader() {
|
|
189
|
+
if (!defaultLoader) {
|
|
190
|
+
defaultLoader = new MembraneConfigLoader();
|
|
191
|
+
}
|
|
192
|
+
return defaultLoader;
|
|
193
|
+
}
|
|
194
|
+
function loadMembraneConfig(cwd, options) {
|
|
195
|
+
if (cwd) {
|
|
196
|
+
const loader = new MembraneConfigLoader(cwd);
|
|
197
|
+
return loader.loadConfig(options);
|
|
198
|
+
}
|
|
199
|
+
return getDefaultMembraneConfigLoader().loadConfig(options);
|
|
200
|
+
}
|
|
201
|
+
function hasMembraneCredentials(cwd) {
|
|
202
|
+
if (cwd) {
|
|
203
|
+
const loader = new MembraneConfigLoader(cwd);
|
|
204
|
+
return loader.hasWorkspaceCredentials();
|
|
205
|
+
}
|
|
206
|
+
return getDefaultMembraneConfigLoader().hasWorkspaceCredentials();
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
exports.CONFIG_FILE_NAME = CONFIG_FILE_NAME;
|
|
210
|
+
exports.MembraneConfigLoader = MembraneConfigLoader;
|
|
211
|
+
exports.getDefaultMembraneConfigLoader = getDefaultMembraneConfigLoader;
|
|
212
|
+
exports.hasMembraneCredentials = hasMembraneCredentials;
|
|
213
|
+
exports.loadMembraneConfig = loadMembraneConfig;
|
|
214
|
+
exports.membraneConfigSchema = membraneConfigSchema;
|
|
215
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sources":["../src/config/index.ts"],"sourcesContent":[null],"names":["z","path","yaml","fs"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUO,MAAM,gBAAgB,GAAG;AAKzB,MAAM,oBAAoB,GAAGA,KAAC,CAAC,MAAM,CAAC;AAC3C,IAAA,YAAY,EAAEA,KAAC,CAAC,MAAM,EAAE;AACxB,IAAA,eAAe,EAAEA,KAAC,CAAC,MAAM,EAAE;AAC3B,IAAA,MAAM,EAAEA,KAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;AAC7B,IAAA,UAAU,EAAEA,KAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;AACjC,IAAA,cAAc,EAAEA,KAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;AACrC,IAAA,WAAW,EAAEA,KAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;AACnC,CAAA;MAqCY,oBAAoB,CAAA;AAQ/B,IAAA,WAAA,CAAY,GAAA,GAAc,OAAO,CAAC,GAAG,EAAE,EAAA;QAP/B,IAAA,CAA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const CONFIG_FILE_NAME = 'membrane.config.yml';
|
|
7
|
+
const membraneConfigSchema = z.object({
|
|
8
|
+
workspaceKey: z.string(),
|
|
9
|
+
workspaceSecret: z.string(),
|
|
10
|
+
apiUri: z.string().optional(),
|
|
11
|
+
consoleUri: z.string().optional(),
|
|
12
|
+
testCustomerId: z.string().optional(),
|
|
13
|
+
accessToken: z.string().optional(),
|
|
14
|
+
});
|
|
15
|
+
class MembraneConfigLoader {
|
|
16
|
+
constructor(cwd = process.cwd()) {
|
|
17
|
+
this.cachedConfig = null;
|
|
18
|
+
this.cwd = cwd;
|
|
19
|
+
}
|
|
20
|
+
loadConfig(options = {}) {
|
|
21
|
+
const { validate = false, useCache = true } = options;
|
|
22
|
+
if (useCache && this.cachedConfig !== null) {
|
|
23
|
+
if (validate) {
|
|
24
|
+
const validation = membraneConfigSchema.safeParse(this.cachedConfig);
|
|
25
|
+
if (!validation.success) {
|
|
26
|
+
throw new Error(`Invalid configuration: ${validation.error.message}`);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return this.cachedConfig;
|
|
30
|
+
}
|
|
31
|
+
const fileConfig = this.loadFromFile();
|
|
32
|
+
const envConfig = this.loadFromEnv();
|
|
33
|
+
const mergedConfig = {
|
|
34
|
+
...fileConfig,
|
|
35
|
+
...envConfig,
|
|
36
|
+
};
|
|
37
|
+
this.cachedConfig = mergedConfig;
|
|
38
|
+
if (validate) {
|
|
39
|
+
const validation = membraneConfigSchema.safeParse(mergedConfig);
|
|
40
|
+
if (!validation.success) {
|
|
41
|
+
throw new Error(`Invalid configuration: ${validation.error.message}`);
|
|
42
|
+
}
|
|
43
|
+
return validation.data;
|
|
44
|
+
}
|
|
45
|
+
return mergedConfig;
|
|
46
|
+
}
|
|
47
|
+
hasValidConfig() {
|
|
48
|
+
try {
|
|
49
|
+
const config = this.loadConfig({ validate: true });
|
|
50
|
+
return Boolean(config.workspaceKey && config.workspaceSecret);
|
|
51
|
+
}
|
|
52
|
+
catch (_a) {
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
hasWorkspaceCredentials() {
|
|
57
|
+
const config = this.loadConfig();
|
|
58
|
+
return Boolean(config.workspaceKey && config.workspaceSecret);
|
|
59
|
+
}
|
|
60
|
+
clearCache() {
|
|
61
|
+
this.cachedConfig = null;
|
|
62
|
+
}
|
|
63
|
+
updateConfig(newConfig) {
|
|
64
|
+
const currentConfig = this.loadConfig({ useCache: false });
|
|
65
|
+
const mergedConfig = {
|
|
66
|
+
...currentConfig,
|
|
67
|
+
...newConfig,
|
|
68
|
+
};
|
|
69
|
+
this.saveToFile(newConfig);
|
|
70
|
+
this.cachedConfig = mergedConfig;
|
|
71
|
+
return mergedConfig;
|
|
72
|
+
}
|
|
73
|
+
saveToFile(config) {
|
|
74
|
+
const configPath = path.join(this.cwd, CONFIG_FILE_NAME);
|
|
75
|
+
const fileConfig = this.loadFromFile();
|
|
76
|
+
const newFileConfig = {
|
|
77
|
+
...fileConfig,
|
|
78
|
+
...config,
|
|
79
|
+
};
|
|
80
|
+
const envConfig = this.loadFromEnv();
|
|
81
|
+
for (const key of Object.keys(envConfig)) {
|
|
82
|
+
if (envConfig[key] === newFileConfig[key]) {
|
|
83
|
+
delete newFileConfig[key];
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
try {
|
|
87
|
+
const yamlStr = yaml.dump(newFileConfig);
|
|
88
|
+
fs.writeFileSync(configPath, yamlStr, 'utf8');
|
|
89
|
+
return true;
|
|
90
|
+
}
|
|
91
|
+
catch (_error) {
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
getCwd() {
|
|
96
|
+
return this.cwd;
|
|
97
|
+
}
|
|
98
|
+
setCwd(newCwd) {
|
|
99
|
+
if (this.cwd !== newCwd) {
|
|
100
|
+
this.cwd = newCwd;
|
|
101
|
+
this.clearCache();
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
loadFromFile() {
|
|
105
|
+
const configPath = path.join(this.cwd, CONFIG_FILE_NAME);
|
|
106
|
+
let configFile;
|
|
107
|
+
try {
|
|
108
|
+
configFile = fs.readFileSync(configPath, 'utf8');
|
|
109
|
+
}
|
|
110
|
+
catch (_a) {
|
|
111
|
+
return {};
|
|
112
|
+
}
|
|
113
|
+
let parsedConfig;
|
|
114
|
+
try {
|
|
115
|
+
parsedConfig = yaml.load(configFile);
|
|
116
|
+
}
|
|
117
|
+
catch (yamlError) {
|
|
118
|
+
throw new Error(`Failed to parse ${CONFIG_FILE_NAME}: ${yamlError.message}`);
|
|
119
|
+
}
|
|
120
|
+
const config = {};
|
|
121
|
+
if (parsedConfig === null || parsedConfig === void 0 ? void 0 : parsedConfig.accessToken) {
|
|
122
|
+
config.accessToken = String(parsedConfig.accessToken);
|
|
123
|
+
}
|
|
124
|
+
if (parsedConfig === null || parsedConfig === void 0 ? void 0 : parsedConfig.workspaceKey) {
|
|
125
|
+
config.workspaceKey = String(parsedConfig.workspaceKey);
|
|
126
|
+
}
|
|
127
|
+
if (parsedConfig === null || parsedConfig === void 0 ? void 0 : parsedConfig.workspaceSecret) {
|
|
128
|
+
config.workspaceSecret = String(parsedConfig.workspaceSecret);
|
|
129
|
+
}
|
|
130
|
+
if (parsedConfig === null || parsedConfig === void 0 ? void 0 : parsedConfig.apiUri) {
|
|
131
|
+
config.apiUri = String(parsedConfig.apiUri);
|
|
132
|
+
}
|
|
133
|
+
if (parsedConfig === null || parsedConfig === void 0 ? void 0 : parsedConfig.consoleUri) {
|
|
134
|
+
config.consoleUri = String(parsedConfig.consoleUri);
|
|
135
|
+
}
|
|
136
|
+
if (parsedConfig === null || parsedConfig === void 0 ? void 0 : parsedConfig.testCustomerId) {
|
|
137
|
+
config.testCustomerId = String(parsedConfig.testCustomerId);
|
|
138
|
+
}
|
|
139
|
+
return config;
|
|
140
|
+
}
|
|
141
|
+
loadFromEnv() {
|
|
142
|
+
const config = {};
|
|
143
|
+
if (process.env.MEMBRANE_ACCESS_TOKEN) {
|
|
144
|
+
config.accessToken = process.env.MEMBRANE_ACCESS_TOKEN;
|
|
145
|
+
}
|
|
146
|
+
if (process.env.MEMBRANE_WORKSPACE_KEY) {
|
|
147
|
+
config.workspaceKey = process.env.MEMBRANE_WORKSPACE_KEY;
|
|
148
|
+
}
|
|
149
|
+
if (process.env.MEMBRANE_WORKSPACE_SECRET) {
|
|
150
|
+
config.workspaceSecret = process.env.MEMBRANE_WORKSPACE_SECRET;
|
|
151
|
+
}
|
|
152
|
+
if (process.env.MEMBRANE_API_URI) {
|
|
153
|
+
config.apiUri = process.env.MEMBRANE_API_URI;
|
|
154
|
+
}
|
|
155
|
+
if (process.env.MEMBRANE_CONSOLE_URI) {
|
|
156
|
+
config.consoleUri = process.env.MEMBRANE_CONSOLE_URI;
|
|
157
|
+
}
|
|
158
|
+
if (process.env.MEMBRANE_TEST_CUSTOMER_ID) {
|
|
159
|
+
config.testCustomerId = process.env.MEMBRANE_TEST_CUSTOMER_ID;
|
|
160
|
+
}
|
|
161
|
+
return config;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
let defaultLoader = null;
|
|
165
|
+
function getDefaultMembraneConfigLoader() {
|
|
166
|
+
if (!defaultLoader) {
|
|
167
|
+
defaultLoader = new MembraneConfigLoader();
|
|
168
|
+
}
|
|
169
|
+
return defaultLoader;
|
|
170
|
+
}
|
|
171
|
+
function loadMembraneConfig(cwd, options) {
|
|
172
|
+
if (cwd) {
|
|
173
|
+
const loader = new MembraneConfigLoader(cwd);
|
|
174
|
+
return loader.loadConfig(options);
|
|
175
|
+
}
|
|
176
|
+
return getDefaultMembraneConfigLoader().loadConfig(options);
|
|
177
|
+
}
|
|
178
|
+
function hasMembraneCredentials(cwd) {
|
|
179
|
+
if (cwd) {
|
|
180
|
+
const loader = new MembraneConfigLoader(cwd);
|
|
181
|
+
return loader.hasWorkspaceCredentials();
|
|
182
|
+
}
|
|
183
|
+
return getDefaultMembraneConfigLoader().hasWorkspaceCredentials();
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
export { CONFIG_FILE_NAME, MembraneConfigLoader, getDefaultMembraneConfigLoader, hasMembraneCredentials, loadMembraneConfig, membraneConfigSchema };
|
|
187
|
+
//# sourceMappingURL=config.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.mjs","sources":["../src/config/index.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;AAUO,MAAM,gBAAgB,GAAG;AAKzB,MAAM,oBAAoB,GAAG,CAAC,CAAC,MAAM,CAAC;AAC3C,IAAA,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE;AACxB,IAAA,eAAe,EAAE,CAAC,CAAC,MAAM,EAAE;AAC3B,IAAA,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;AAC7B,IAAA,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;AACjC,IAAA,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;AACrC,IAAA,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;AACnC,CAAA;MAqCY,oBAAoB,CAAA;AAQ/B,IAAA,WAAA,CAAY,GAAA,GAAc,OAAO,CAAC,GAAG,EAAE,EAAA;QAP/B,IAAA,CAAA,YAAY,GAAiC,IAAI;AAQvD,QAAA,IAAI,CAAC,GAAG,GAAG,GAAG;IAChB;IAQA,UAAU,CAAC,UAA6B,EAAE,EAAA;QACxC,MAAM,EAAE,QAAQ,GAAG,KAAK,EAAE,QAAQ,GAAG,IAAI,EAAE,GAAG,OAAO;QAGrD,IAAI,QAAQ,IAAI,IAAI,CAAC,YAAY,KAAK,IAAI,EAAE;YAC1C,IAAI,QAAQ,EAAE;gBACZ,MAAM,UAAU,GAAG,oBAAoB,CAAC,SAAS,CAAC,IAAI,CAAC,YAAY,CAAC;AACpE,gBAAA,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE;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rC,8BAA8B,GAAA;IAC5C,IAAI,CAAC,aAAa,EAAE;AAClB,QAAA,aAAa,GAAG,IAAI,oBAAoB,EAAE;IAC5C;AACA,IAAA,OAAO,aAAa;AACtB;AAQM,SAAU,kBAAkB,CAAC,GAAY,EAAE,OAA2B,EAAA;IAC1E,IAAI,GAAG,EAAE;AACP,QAAA,MAAM,MAAM,GAAG,IAAI,oBAAoB,CAAC,GAAG,CAAC;AAC5C,QAAA,OAAO,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC;IACnC;AACA,IAAA,OAAO,8BAA8B,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC;AAC7D;AAMM,SAAU,sBAAsB,CAAC,GAAY,EAAA;IACjD,IAAI,GAAG,EAAE;AACP,QAAA,MAAM,MAAM,GAAG,IAAI,oBAAoB,CAAC,GAAG,CAAC;AAC5C,QAAA,OAAO,MAAM,CAAC,uBAAuB,EAAE;IACzC;AACA,IAAA,OAAO,8BAA8B,EAAE,CAAC,uBAAuB,EAAE;AACnE;;;;"}
|
|
@@ -65,7 +65,7 @@ export declare class ConnectionAccessor {
|
|
|
65
65
|
archivedAt?: string | undefined;
|
|
66
66
|
isDeactivated?: boolean | undefined;
|
|
67
67
|
meta?: Record<string, any> | undefined;
|
|
68
|
-
|
|
68
|
+
buildingAgentSessionId?: string | undefined;
|
|
69
69
|
clientAction?: {
|
|
70
70
|
type: "connect" | "provide-input";
|
|
71
71
|
description: string;
|
|
@@ -72,7 +72,7 @@ export declare class IntegrationAccessor extends ElementAccessor<IntegrationApiR
|
|
|
72
72
|
archivedAt?: string | undefined;
|
|
73
73
|
isDeactivated?: boolean | undefined;
|
|
74
74
|
meta?: Record<string, any> | undefined;
|
|
75
|
-
|
|
75
|
+
buildingAgentSessionId?: string | undefined;
|
|
76
76
|
clientAction?: {
|
|
77
77
|
type: "connect" | "provide-input";
|
|
78
78
|
description: string;
|
|
@@ -57,9 +57,18 @@ export declare const CreateAgentSession: z.ZodObject<{
|
|
|
57
57
|
agentName: z.ZodOptional<z.ZodEnum<typeof AgentName>>;
|
|
58
58
|
}, z.core.$strip>;
|
|
59
59
|
export type CreateAgentSession = z.infer<typeof CreateAgentSession>;
|
|
60
|
+
export declare const AgentSessionAttachment: z.ZodObject<{
|
|
61
|
+
title: z.ZodString;
|
|
62
|
+
data: z.ZodUnknown;
|
|
63
|
+
}, z.core.$strip>;
|
|
64
|
+
export type AgentSessionAttachment = z.infer<typeof AgentSessionAttachment>;
|
|
60
65
|
export declare const AgentSessionInputSchema: z.ZodObject<{
|
|
61
66
|
input: z.ZodString;
|
|
62
67
|
synthetic: z.ZodOptional<z.ZodBoolean>;
|
|
68
|
+
attachments: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
69
|
+
title: z.ZodString;
|
|
70
|
+
data: z.ZodUnknown;
|
|
71
|
+
}, z.core.$strip>>>;
|
|
63
72
|
}, z.core.$strip>;
|
|
64
73
|
export type AgentSessionInput = z.infer<typeof AgentSessionInputSchema>;
|
|
65
74
|
export declare const PatchAgentSessionSchema: z.ZodObject<{
|
|
@@ -26,3 +26,4 @@ export declare const GenericFunctionDefinition: z.ZodObject<{
|
|
|
26
26
|
}>>;
|
|
27
27
|
}, z.core.$loose>;
|
|
28
28
|
export type GenericFunctionDefinition = z.infer<typeof GenericFunctionDefinition>;
|
|
29
|
+
export declare function validateFunctionDefinitions(functions: Record<string, GenericFunctionDefinition>, schema: z.ZodType): void;
|
|
@@ -19,12 +19,12 @@ export declare const FunctionDefinition: z.ZodUnion<readonly [z.ZodObject<{
|
|
|
19
19
|
mapping: z.ZodObject<{
|
|
20
20
|
path: z.ZodString;
|
|
21
21
|
method: z.ZodString;
|
|
22
|
-
requestMapping: z.ZodObject<{
|
|
22
|
+
requestMapping: z.ZodOptional<z.ZodObject<{
|
|
23
23
|
pathParameters: z.ZodOptional<z.ZodAny>;
|
|
24
24
|
query: z.ZodOptional<z.ZodAny>;
|
|
25
25
|
data: z.ZodOptional<z.ZodAny>;
|
|
26
26
|
headers: z.ZodOptional<z.ZodAny>;
|
|
27
|
-
}, z.core.$strip
|
|
27
|
+
}, z.core.$strip>>;
|
|
28
28
|
responseMapping: z.ZodOptional<z.ZodAny>;
|
|
29
29
|
}, z.core.$strip>;
|
|
30
30
|
}, z.core.$strip>, z.ZodObject<{
|
|
@@ -10,24 +10,24 @@ export type RequestMappingSchema = z.infer<typeof RequestMappingSchema>;
|
|
|
10
10
|
export declare const RestApiMappingSchema: z.ZodObject<{
|
|
11
11
|
path: z.ZodString;
|
|
12
12
|
method: z.ZodString;
|
|
13
|
-
requestMapping: z.ZodObject<{
|
|
13
|
+
requestMapping: z.ZodOptional<z.ZodObject<{
|
|
14
14
|
pathParameters: z.ZodOptional<z.ZodAny>;
|
|
15
15
|
query: z.ZodOptional<z.ZodAny>;
|
|
16
16
|
data: z.ZodOptional<z.ZodAny>;
|
|
17
17
|
headers: z.ZodOptional<z.ZodAny>;
|
|
18
|
-
}, z.core.$strip
|
|
18
|
+
}, z.core.$strip>>;
|
|
19
19
|
responseMapping: z.ZodOptional<z.ZodAny>;
|
|
20
20
|
}, z.core.$strip>;
|
|
21
21
|
export type RestApiMappingSchema = z.infer<typeof RestApiMappingSchema>;
|
|
22
22
|
export declare const OpenapiMappingSchema: z.ZodObject<{
|
|
23
23
|
path: z.ZodString;
|
|
24
24
|
method: z.ZodString;
|
|
25
|
-
requestMapping: z.ZodObject<{
|
|
25
|
+
requestMapping: z.ZodOptional<z.ZodObject<{
|
|
26
26
|
pathParameters: z.ZodOptional<z.ZodAny>;
|
|
27
27
|
query: z.ZodOptional<z.ZodAny>;
|
|
28
28
|
data: z.ZodOptional<z.ZodAny>;
|
|
29
29
|
headers: z.ZodOptional<z.ZodAny>;
|
|
30
|
-
}, z.core.$strip
|
|
30
|
+
}, z.core.$strip>>;
|
|
31
31
|
responseMapping: z.ZodOptional<z.ZodAny>;
|
|
32
32
|
}, z.core.$strip>;
|
|
33
33
|
export type OpenapiMappingSchema = z.infer<typeof OpenapiMappingSchema>;
|
|
@@ -36,12 +36,12 @@ export declare const RestApiMappingFunction: z.ZodObject<{
|
|
|
36
36
|
mapping: z.ZodObject<{
|
|
37
37
|
path: z.ZodString;
|
|
38
38
|
method: z.ZodString;
|
|
39
|
-
requestMapping: z.ZodObject<{
|
|
39
|
+
requestMapping: z.ZodOptional<z.ZodObject<{
|
|
40
40
|
pathParameters: z.ZodOptional<z.ZodAny>;
|
|
41
41
|
query: z.ZodOptional<z.ZodAny>;
|
|
42
42
|
data: z.ZodOptional<z.ZodAny>;
|
|
43
43
|
headers: z.ZodOptional<z.ZodAny>;
|
|
44
|
-
}, z.core.$strip
|
|
44
|
+
}, z.core.$strip>>;
|
|
45
45
|
responseMapping: z.ZodOptional<z.ZodAny>;
|
|
46
46
|
}, z.core.$strip>;
|
|
47
47
|
}, z.core.$strip>;
|
package/dist/dts/index.node.d.ts
CHANGED
package/dist/dts/orgs/types.d.ts
CHANGED
|
@@ -650,6 +650,7 @@ export declare const AccountResponse: z.ZodObject<{
|
|
|
650
650
|
isThrottled: z.ZodOptional<z.ZodBoolean>;
|
|
651
651
|
isDisabled: z.ZodOptional<z.ZodBoolean>;
|
|
652
652
|
isBackgroundJobsDisabled: z.ZodOptional<z.ZodBoolean>;
|
|
653
|
+
isReadOnly: z.ZodOptional<z.ZodBoolean>;
|
|
653
654
|
lastExternalApiRequestDate: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
654
655
|
}, z.core.$strip>>;
|
|
655
656
|
superAdminToken: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
package/dist/dts/ui.d.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { MembraneApiClient } from './api-client';
|
|
2
2
|
import { ConnectionApiResponse, ConnectUIOptions } from './workspace-elements/api/connections-api';
|
|
3
3
|
export { ConnectUIOptions };
|
|
4
|
+
export interface ConnectionUIOptions {
|
|
5
|
+
connectionId: string;
|
|
6
|
+
theme?: 'light' | 'dark' | 'auto';
|
|
7
|
+
}
|
|
4
8
|
export interface UNSAFE_AgentSessionUIOptions {
|
|
5
9
|
sessionId: string;
|
|
6
10
|
theme?: 'light' | 'dark' | 'auto';
|
|
@@ -9,5 +13,6 @@ export declare class UI {
|
|
|
9
13
|
private client;
|
|
10
14
|
constructor(client: MembraneApiClient);
|
|
11
15
|
connect(options?: ConnectUIOptions): Promise<ConnectionApiResponse | null>;
|
|
16
|
+
connection(options: ConnectionUIOptions): Promise<ConnectionApiResponse | null>;
|
|
12
17
|
UNSAFE_agentSession(options: UNSAFE_AgentSessionUIOptions): Promise<void>;
|
|
13
18
|
}
|
|
@@ -171,7 +171,7 @@ export declare const ActionRunLogRecordApiResponse: z.ZodObject<{
|
|
|
171
171
|
archivedAt: z.ZodOptional<z.ZodString>;
|
|
172
172
|
isDeactivated: z.ZodOptional<z.ZodBoolean>;
|
|
173
173
|
meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
174
|
-
|
|
174
|
+
buildingAgentSessionId: z.ZodOptional<z.ZodString>;
|
|
175
175
|
clientAction: z.ZodOptional<z.ZodObject<{
|
|
176
176
|
type: z.ZodEnum<{
|
|
177
177
|
connect: "connect";
|
|
@@ -389,7 +389,7 @@ export declare const FindActionRunLogsResponse: z.ZodObject<{
|
|
|
389
389
|
archivedAt: z.ZodOptional<z.ZodString>;
|
|
390
390
|
isDeactivated: z.ZodOptional<z.ZodBoolean>;
|
|
391
391
|
meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
392
|
-
|
|
392
|
+
buildingAgentSessionId: z.ZodOptional<z.ZodString>;
|
|
393
393
|
clientAction: z.ZodOptional<z.ZodObject<{
|
|
394
394
|
type: z.ZodEnum<{
|
|
395
395
|
connect: "connect";
|