@membranehq/sdk 0.20.0 → 0.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,38 @@
1
+ import { 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 };
@@ -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,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+
6
+ 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;oBACvB,MAAM,IAAI,KAAK,CAAC,CAAA,uBAAA,EAA0B,UAAU,CAAC,KAAK,CAAC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AAI,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;;;;"}
@@ -177,7 +177,6 @@ export declare function createOrUpdateConnection(options: {
177
177
  connectionId?: string;
178
178
  allowMultipleConnections?: boolean;
179
179
  connectionRequestId?: string;
180
- token: string;
181
180
  apiUri: string;
182
181
  redirectUri?: string;
183
182
  onPopupClosed?: () => void;
@@ -0,0 +1 @@
1
+ export {};
@@ -1,2 +1 @@
1
1
  export * from './index.browser';
2
- export * from './config';
@@ -87,7 +87,6 @@ export declare const IntegrationExportProperties: z.ZodObject<{
87
87
  uuid: z.ZodOptional<z.ZodString>;
88
88
  meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
89
89
  externalAppUuid: z.ZodOptional<z.ZodString>;
90
- parameters: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
91
90
  logoUri: z.ZodOptional<z.ZodString>;
92
91
  appUuid: z.ZodOptional<z.ZodString>;
93
92
  connectorVersion: z.ZodOptional<z.ZodString>;
@@ -11417,7 +11417,6 @@ declare const IntegrationExportProperties: z.ZodObject<{
11417
11417
  uuid: z.ZodOptional<z.ZodString>;
11418
11418
  meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
11419
11419
  externalAppUuid: z.ZodOptional<z.ZodString>;
11420
- parameters: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
11421
11420
  logoUri: z.ZodOptional<z.ZodString>;
11422
11421
  appUuid: z.ZodOptional<z.ZodString>;
11423
11422
  connectorVersion: z.ZodOptional<z.ZodString>;
@@ -15889,7 +15888,6 @@ declare function createOrUpdateConnection(options: {
15889
15888
  connectionId?: string;
15890
15889
  allowMultipleConnections?: boolean;
15891
15890
  connectionRequestId?: string;
15892
- token: string;
15893
15891
  apiUri: string;
15894
15892
  redirectUri?: string;
15895
15893
  onPopupClosed?: () => void;
@@ -11417,7 +11417,6 @@ declare const IntegrationExportProperties: z.ZodObject<{
11417
11417
  uuid: z.ZodOptional<z.ZodString>;
11418
11418
  meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
11419
11419
  externalAppUuid: z.ZodOptional<z.ZodString>;
11420
- parameters: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
11421
11420
  logoUri: z.ZodOptional<z.ZodString>;
11422
11421
  appUuid: z.ZodOptional<z.ZodString>;
11423
11422
  connectorVersion: z.ZodOptional<z.ZodString>;
@@ -15889,7 +15888,6 @@ declare function createOrUpdateConnection(options: {
15889
15888
  connectionId?: string;
15890
15889
  allowMultipleConnections?: boolean;
15891
15890
  connectionRequestId?: string;
15892
- token: string;
15893
15891
  apiUri: string;
15894
15892
  redirectUri?: string;
15895
15893
  onPopupClosed?: () => void;
@@ -9943,6 +9943,7 @@ const IntegrationEditableProperties = BaseMembraneInterfaceEditableProperties.ex
9943
9943
  const IntegrationExportProperties = IntegrationEditableProperties.omit({
9944
9944
  connectorId: true,
9945
9945
  externalAppId: true,
9946
+ parameters: true,
9946
9947
  });
9947
9948
  const AppliedToIntegrations = (elementSchema) => z.z.array(z.z.object({
9948
9949
  element: elementSchema,
@@ -14904,7 +14905,6 @@ class ConnectionAccessor {
14904
14905
  authOptionKey,
14905
14906
  connectorParameters,
14906
14907
  apiUri: this.client.apiUri,
14907
- token: await this.client.getToken(),
14908
14908
  onPopupClosed,
14909
14909
  });
14910
14910
  }
@@ -14994,16 +14994,17 @@ class ConnectionProxy {
14994
14994
  }
14995
14995
  }
14996
14996
  async function createOrUpdateConnection(options) {
14997
- const { connectionId, integrationKey, integrationId, connectorId, connectorVersion, name, input, connectorParameters, allowMultipleConnections, authOptionKey, connectionRequestId, apiUri, token, redirectUri, onPopupClosed, } = options !== null && options !== void 0 ? options : {};
14997
+ const { client, connectionId, integrationKey, integrationId, connectorId, connectorVersion, name, input, connectorParameters, allowMultipleConnections, authOptionKey, connectionRequestId, apiUri, redirectUri, onPopupClosed, } = options !== null && options !== void 0 ? options : {};
14998
14998
  let connectionType = await detectConnectionType(options);
14999
14999
  if (redirectUri) {
15000
15000
  connectionType = ConnectionType.REDIRECT;
15001
15001
  }
15002
+ const freshToken = await client.getToken();
15002
15003
  const connectPath = 'connect';
15003
15004
  return new Promise((resolve, reject) => {
15004
15005
  const requestId = simpleUniqueId() + simpleUniqueId();
15005
15006
  const payload = {
15006
- token,
15007
+ token: freshToken,
15007
15008
  input,
15008
15009
  connectorParameters,
15009
15010
  integrationKey,
@@ -15032,7 +15033,7 @@ async function createOrUpdateConnection(options) {
15032
15033
  const { stopSSE } = createSSEListener({
15033
15034
  apiUri: apiUri,
15034
15035
  requestId,
15035
- token,
15036
+ token: freshToken,
15036
15037
  handler: eventHandler,
15037
15038
  });
15038
15039
  function cleanup() {
@@ -15336,7 +15337,6 @@ class IntegrationAccessor extends ElementAccessor {
15336
15337
  authOptionKey,
15337
15338
  allowMultipleConnections,
15338
15339
  apiUri: this.client.apiUri,
15339
- token: await this.client.getToken(),
15340
15340
  redirectUri: sameWindow ? redirectUri : undefined,
15341
15341
  onPopupClosed,
15342
15342
  });
@@ -16191,7 +16191,6 @@ class MembraneClient extends MembraneApiClient {
16191
16191
  ...options,
16192
16192
  client: this,
16193
16193
  apiUri: this.apiUri,
16194
- token: await this.getToken(),
16195
16194
  redirectUri: options.sameWindow ? options.redirectUri : undefined,
16196
16195
  });
16197
16196
  }