@ptkl/sdk 1.0.0 → 1.0.2

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.
@@ -239,6 +239,19 @@ var ProtokolSDK010 = (function (exports, axios) {
239
239
  options
240
240
  });
241
241
  }
242
+ /**
243
+ * Create many models
244
+ *
245
+ * @param data
246
+ * @param options
247
+ * @returns
248
+ */
249
+ async createMany(data, options) {
250
+ return await this.client.post(`${this.getComponentPath()}/models/bulk`, {
251
+ data,
252
+ options
253
+ });
254
+ }
242
255
  /**
243
256
  * Modify models by filters
244
257
  *
@@ -642,6 +655,17 @@ var ProtokolSDK010 = (function (exports, axios) {
642
655
  async create(data) {
643
656
  return await this.client.post("/v3/system/component/create", data);
644
657
  }
658
+ /**
659
+ * Setup a component with settings in a single atomic operation.
660
+ * This is more comprehensive than create as it handles component creation
661
+ * and settings initialization together.
662
+ *
663
+ * @param data - Component setup data including name, settings, versions, etc.
664
+ * @returns Promise resolving to the created/updated component
665
+ */
666
+ async setup(data) {
667
+ return await this.client.post("/v3/system/component/setup", data);
668
+ }
645
669
  }
646
670
 
647
671
  class Thunder extends PlatformBaseClient {
package/dist/index.0.9.js CHANGED
@@ -40,28 +40,28 @@ var ProtokolSDK09 = (function (exports, axios) {
40
40
  let { env = null, token = null, host = null, } = options !== null && options !== void 0 ? options : {};
41
41
  let headers = {};
42
42
  var project_uuid = null;
43
- if (isBrowser) {
44
- if (sessionStorage.getItem('protokol_context') == "forge") {
45
- headers['X-Project-Env'] = (_a = sessionStorage.getItem('forge_app_env')) !== null && _a !== void 0 ? _a : "dev";
46
- }
47
- else {
48
- headers['X-Project-Env'] = (_b = localStorage.getItem('current_env')) !== null && _b !== void 0 ? _b : "dev";
49
- }
50
- }
51
- else if (isNode) {
52
- host = (_c = host !== null && host !== void 0 ? host : process.env.API_HOST) !== null && _c !== void 0 ? _c : null;
53
- env = (_d = env !== null && env !== void 0 ? env : process.env.PROJECT_ENV) !== null && _d !== void 0 ? _d : null;
54
- token = (_e = token !== null && token !== void 0 ? token : process.env.PROJECT_API_TOKEN) !== null && _e !== void 0 ? _e : null;
55
- project_uuid = (_f = process.env.PROJECT_UUID) !== null && _f !== void 0 ? _f : null;
56
- }
57
- else if (isSandbox) {
43
+ if (isBrowser || isSandbox) {
58
44
  // @ts-ignore
59
45
  const __global_env__ = window === null || window === void 0 ? void 0 : window.__ENV_VARIABLES__;
60
- host = (_g = __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.API_HOST) !== null && _g !== void 0 ? _g : host;
46
+ host = (_a = __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.API_HOST) !== null && _a !== void 0 ? _a : host;
61
47
  // @ts-ignore
62
48
  env = env !== null && env !== void 0 ? env : __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_ENV;
63
49
  token = token !== null && token !== void 0 ? token : __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_API_TOKEN;
64
50
  project_uuid = __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_UUID;
51
+ if (isBrowser) {
52
+ if (sessionStorage.getItem('protokol_context') == "forge") {
53
+ headers['X-Project-Env'] = (_b = sessionStorage.getItem('forge_app_env')) !== null && _b !== void 0 ? _b : "dev";
54
+ }
55
+ else {
56
+ headers['X-Project-Env'] = (_c = localStorage.getItem('current_env')) !== null && _c !== void 0 ? _c : "dev";
57
+ }
58
+ }
59
+ }
60
+ else if (isNode) {
61
+ host = (_d = host !== null && host !== void 0 ? host : process.env.API_HOST) !== null && _d !== void 0 ? _d : null;
62
+ env = (_e = env !== null && env !== void 0 ? env : process.env.PROJECT_ENV) !== null && _e !== void 0 ? _e : null;
63
+ token = (_f = token !== null && token !== void 0 ? token : process.env.PROJECT_API_TOKEN) !== null && _f !== void 0 ? _f : null;
64
+ project_uuid = (_g = process.env.PROJECT_UUID) !== null && _g !== void 0 ? _g : null;
65
65
  }
66
66
  if (token) {
67
67
  headers['Authorization'] = `Bearer ${token}`;
@@ -1240,27 +1240,27 @@ var ProtokolSDK09 = (function (exports, axios) {
1240
1240
  let { env = null, token = null, host = null, } = options !== null && options !== void 0 ? options : {};
1241
1241
  let headers = {};
1242
1242
  var project_uuid = null;
1243
- if (isBrowser) {
1244
- if (sessionStorage.getItem('protokol_context') == "forge") {
1245
- headers['X-Project-Env'] = (_a = sessionStorage.getItem('forge_app_env')) !== null && _a !== void 0 ? _a : "dev";
1246
- }
1247
- else {
1248
- headers['X-Project-Env'] = (_b = localStorage.getItem('current_env')) !== null && _b !== void 0 ? _b : "dev";
1249
- }
1250
- }
1251
- else if (isNode) {
1252
- host = (_c = host !== null && host !== void 0 ? host : process.env.API_HOST) !== null && _c !== void 0 ? _c : null;
1253
- env = (_d = env !== null && env !== void 0 ? env : process.env.PROJECT_ENV) !== null && _d !== void 0 ? _d : null;
1254
- token = (_e = token !== null && token !== void 0 ? token : process.env.PROJECT_API_TOKEN) !== null && _e !== void 0 ? _e : null;
1255
- project_uuid = (_f = process.env.PROJECT_UUID) !== null && _f !== void 0 ? _f : null;
1256
- }
1257
- else if (isSandbox) {
1243
+ if (isBrowser || isSandbox) {
1258
1244
  // @ts-ignore
1259
1245
  const __global_env__ = window === null || window === void 0 ? void 0 : window.__ENV_VARIABLES__;
1260
- host = (_g = __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.API_HOST) !== null && _g !== void 0 ? _g : host;
1246
+ host = (_a = __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.INTEGRATION_API) !== null && _a !== void 0 ? _a : host;
1261
1247
  // @ts-ignore
1262
1248
  env = env !== null && env !== void 0 ? env : __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_ENV;
1263
1249
  token = token !== null && token !== void 0 ? token : __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_API_TOKEN;
1250
+ if (isBrowser) {
1251
+ if (sessionStorage.getItem('protokol_context') == "forge") {
1252
+ headers['X-Project-Env'] = (_b = sessionStorage.getItem('forge_app_env')) !== null && _b !== void 0 ? _b : "dev";
1253
+ }
1254
+ else {
1255
+ headers['X-Project-Env'] = (_c = localStorage.getItem('current_env')) !== null && _c !== void 0 ? _c : "dev";
1256
+ }
1257
+ }
1258
+ }
1259
+ else if (isNode) {
1260
+ host = (_d = host !== null && host !== void 0 ? host : process.env.INTEGRATION_API) !== null && _d !== void 0 ? _d : null;
1261
+ env = (_e = env !== null && env !== void 0 ? env : process.env.PROJECT_ENV) !== null && _e !== void 0 ? _e : null;
1262
+ token = (_f = token !== null && token !== void 0 ? token : process.env.PROJECT_API_TOKEN) !== null && _f !== void 0 ? _f : null;
1263
+ project_uuid = (_g = process.env.PROJECT_UUID) !== null && _g !== void 0 ? _g : null;
1264
1264
  }
1265
1265
  if (token) {
1266
1266
  headers['Authorization'] = `Bearer ${token}`;
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ptkl/sdk",
3
- "version": "0.10.2",
3
+ "version": "1.0.1",
4
4
  "scripts": {
5
5
  "build": "rollup -c",
6
6
  "build:monaco": "npm run build && node scripts/generate-monaco-types.cjs",
@@ -1,4 +1,4 @@
1
- import { FindParams, FindOptions, FindResponse, FindAdvancedParams, FindAggregateParams, Model, UpdateOptions, ModifyOptions, StreamHandler, AggregateChainable, ComponentOptions } from "../types/component";
1
+ import { FindParams, FindOptions, FindResponse, FindAdvancedParams, FindAggregateParams, Model, UpdateOptions, ModifyOptions, StreamHandler, AggregateChainable, ComponentOptions, UpdateManyOptions, CreateManyOptions } from "../types/component";
2
2
  import PlatformBaseClient from "./platformBaseClient";
3
3
  import { AxiosResponse } from "axios";
4
4
  export default class Component extends PlatformBaseClient {
@@ -68,7 +68,15 @@ export default class Component extends PlatformBaseClient {
68
68
  * @param options
69
69
  * @returns
70
70
  */
71
- updateMany(data: Record<string, any>[], options: UpdateOptions): Promise<AxiosResponse<any, any>>;
71
+ updateMany(data: Record<string, any>[], options: UpdateManyOptions): Promise<AxiosResponse<any, any>>;
72
+ /**
73
+ * Create many models
74
+ *
75
+ * @param data
76
+ * @param options
77
+ * @returns
78
+ */
79
+ createMany(data: Record<string, any>[], options: CreateManyOptions): Promise<AxiosResponse<any, any>>;
72
80
  /**
73
81
  * Modify models by filters
74
82
  *
@@ -1,7 +1,16 @@
1
1
  import { AxiosResponse } from "axios";
2
- import { ComponentListResponse } from "../types/component";
2
+ import { ComponentListResponse, SetupData, ComponentCreateResponse } from "../types/component";
3
3
  import PlatformBaseClient from "./platformBaseClient";
4
4
  export default class ComponentUtils extends PlatformBaseClient {
5
5
  list(): Promise<AxiosResponse<ComponentListResponse>>;
6
6
  create(data: any): Promise<AxiosResponse<any, any>>;
7
+ /**
8
+ * Setup a component with settings in a single atomic operation.
9
+ * This is more comprehensive than create as it handles component creation
10
+ * and settings initialization together.
11
+ *
12
+ * @param data - Component setup data including name, settings, versions, etc.
13
+ * @returns Promise resolving to the created/updated component
14
+ */
15
+ setup(data: SetupData): Promise<AxiosResponse<ComponentCreateResponse>>;
7
16
  }
@@ -19205,6 +19205,19 @@ class Component extends PlatformBaseClient {
19205
19205
  options
19206
19206
  });
19207
19207
  }
19208
+ /**
19209
+ * Create many models
19210
+ *
19211
+ * @param data
19212
+ * @param options
19213
+ * @returns
19214
+ */
19215
+ async createMany(data, options) {
19216
+ return await this.client.post(`${this.getComponentPath()}/models/bulk`, {
19217
+ data,
19218
+ options
19219
+ });
19220
+ }
19208
19221
  /**
19209
19222
  * Modify models by filters
19210
19223
  *
@@ -19608,6 +19621,17 @@ class ComponentUtils extends PlatformBaseClient {
19608
19621
  async create(data) {
19609
19622
  return await this.client.post("/v3/system/component/create", data);
19610
19623
  }
19624
+ /**
19625
+ * Setup a component with settings in a single atomic operation.
19626
+ * This is more comprehensive than create as it handles component creation
19627
+ * and settings initialization together.
19628
+ *
19629
+ * @param data - Component setup data including name, settings, versions, etc.
19630
+ * @returns Promise resolving to the created/updated component
19631
+ */
19632
+ async setup(data) {
19633
+ return await this.client.post("/v3/system/component/setup", data);
19634
+ }
19611
19635
  }
19612
19636
 
19613
19637
  class Thunder extends PlatformBaseClient {
@@ -238,6 +238,19 @@ class Component extends PlatformBaseClient {
238
238
  options
239
239
  });
240
240
  }
241
+ /**
242
+ * Create many models
243
+ *
244
+ * @param data
245
+ * @param options
246
+ * @returns
247
+ */
248
+ async createMany(data, options) {
249
+ return await this.client.post(`${this.getComponentPath()}/models/bulk`, {
250
+ data,
251
+ options
252
+ });
253
+ }
241
254
  /**
242
255
  * Modify models by filters
243
256
  *
@@ -641,6 +654,17 @@ class ComponentUtils extends PlatformBaseClient {
641
654
  async create(data) {
642
655
  return await this.client.post("/v3/system/component/create", data);
643
656
  }
657
+ /**
658
+ * Setup a component with settings in a single atomic operation.
659
+ * This is more comprehensive than create as it handles component creation
660
+ * and settings initialization together.
661
+ *
662
+ * @param data - Component setup data including name, settings, versions, etc.
663
+ * @returns Promise resolving to the created/updated component
664
+ */
665
+ async setup(data) {
666
+ return await this.client.post("/v3/system/component/setup", data);
667
+ }
644
668
  }
645
669
 
646
670
  class Thunder extends PlatformBaseClient {
@@ -65,7 +65,13 @@ type Model = {
65
65
  [key: string]: any;
66
66
  };
67
67
  type UpdateOptions = {
68
- force_update_protected_fields: boolean;
68
+ forceUpdateProtectedFields: boolean;
69
+ };
70
+ type UpdateManyOptions = UpdateOptions & {
71
+ rollbackOnError: boolean;
72
+ };
73
+ type CreateManyOptions = {
74
+ rollbackOnError: boolean;
69
75
  };
70
76
  type ModifyOptions = {
71
77
  upsert: boolean;
@@ -107,4 +113,186 @@ type ComponentListItem = {
107
113
  storage_size: number;
108
114
  };
109
115
  type ComponentListResponse = ComponentListItem[];
110
- export { FindParams, FindOptions, FindResponse, FindAdvancedParams, FindAggregateParams, Model, UpdateOptions, ModifyOptions, ComponentOptions, ComponentListResponse, ComponentListItem, ComponentLabel, ComponentWorkspace, StreamCallback, StreamHandler, AggregateChainable, };
116
+ type FieldRoles = {
117
+ see: string[];
118
+ edit: string[];
119
+ };
120
+ type Context = {
121
+ key: string;
122
+ value: any;
123
+ };
124
+ type FieldConstraints = {
125
+ required?: boolean;
126
+ unique?: boolean;
127
+ placeholder?: string;
128
+ default?: string;
129
+ length?: {
130
+ min?: number | null;
131
+ max?: number | null;
132
+ };
133
+ not_allowed_words?: string;
134
+ regex?: string;
135
+ date?: {
136
+ pattern?: string;
137
+ disable_past_dates?: boolean;
138
+ disable_future_dates?: boolean;
139
+ disabled_dates?: {
140
+ dates?: string[];
141
+ to?: string;
142
+ from?: string;
143
+ days?: number[];
144
+ days_of_month?: number[];
145
+ ranges?: Array<{
146
+ from: string;
147
+ to: string;
148
+ }>;
149
+ };
150
+ highlighted_dates?: {
151
+ dates?: string[];
152
+ to?: string;
153
+ from?: string;
154
+ days?: number[];
155
+ days_of_month?: number[];
156
+ ranges?: Array<{
157
+ from: string;
158
+ to: string;
159
+ }>;
160
+ include_disabled?: boolean;
161
+ };
162
+ };
163
+ selectables?: {
164
+ items?: any[];
165
+ multiple?: boolean;
166
+ range?: {
167
+ from: number;
168
+ to: number;
169
+ };
170
+ custom?: boolean;
171
+ };
172
+ table?: {
173
+ search?: boolean;
174
+ per_page?: number;
175
+ save_on_create?: boolean;
176
+ fields?: SettingsField[];
177
+ };
178
+ relation?: {
179
+ label?: string;
180
+ searchOn?: string[];
181
+ };
182
+ };
183
+ type SettingsField = {
184
+ name: string;
185
+ label: Record<string, any>;
186
+ key: string;
187
+ type: string;
188
+ description?: Record<string, any>;
189
+ module?: string;
190
+ group?: string;
191
+ sortOrder?: number;
192
+ visible?: boolean;
193
+ protected?: boolean;
194
+ roles?: FieldRoles;
195
+ context?: Context[];
196
+ constraints?: FieldConstraints;
197
+ relation?: {
198
+ foreign?: string;
199
+ key?: string[];
200
+ type?: string;
201
+ foreign_uuid?: string | null;
202
+ };
203
+ mutators?: {
204
+ get?: string;
205
+ set?: string;
206
+ };
207
+ provided_template?: boolean;
208
+ provided_template_component?: string;
209
+ component_template?: string;
210
+ template?: string;
211
+ permissions?: string[];
212
+ };
213
+ type Filters = {
214
+ filter?: string;
215
+ filterOn?: string[];
216
+ dateField?: string;
217
+ dateFrom?: string;
218
+ dateTo?: string;
219
+ $adv?: Record<string, any>;
220
+ };
221
+ type PresetContext = {
222
+ filters?: Filters;
223
+ default?: boolean;
224
+ locked?: boolean;
225
+ expr?: string;
226
+ };
227
+ type Preset = {
228
+ name: string;
229
+ roles: string[];
230
+ context: PresetContext;
231
+ };
232
+ type Function = {
233
+ name: string;
234
+ expr: string;
235
+ };
236
+ type TemplatesDist = {
237
+ sdk_version: number;
238
+ sdk_engine: string;
239
+ dist: Record<string, any>;
240
+ };
241
+ type Settings = {
242
+ version?: string;
243
+ appearance?: {
244
+ list_entrypoint?: string;
245
+ create_entrypoint?: string;
246
+ edit_entrypoint?: string;
247
+ };
248
+ list?: {
249
+ quick_actions?: boolean;
250
+ perPage?: number;
251
+ fields?: Array<{
252
+ key: string;
253
+ label: Record<string, any>;
254
+ name?: string;
255
+ sortOrder?: number;
256
+ sortable?: boolean;
257
+ filterable?: boolean;
258
+ sortDirection?: string;
259
+ sortByFormatted?: boolean;
260
+ filterByFormatted?: boolean;
261
+ formatterEditor?: string;
262
+ variant?: string;
263
+ formatter?: string;
264
+ provided_template_component?: string;
265
+ component_template?: string;
266
+ }>;
267
+ };
268
+ fields?: SettingsField[];
269
+ model?: {
270
+ events?: Record<string, any>[];
271
+ unique_indexes_combinations?: string[][];
272
+ };
273
+ presets?: Preset[];
274
+ templates?: Record<string, any>[];
275
+ templates_dist?: TemplatesDist;
276
+ config?: Record<string, any>;
277
+ functions?: Function[];
278
+ };
279
+ type SetupData = {
280
+ name: string;
281
+ label?: Record<string, any>;
282
+ tag: string;
283
+ scope?: string;
284
+ public_version?: string;
285
+ dev_version?: string;
286
+ project_uuid?: string;
287
+ workspaces?: string[];
288
+ roles?: string[];
289
+ settings?: Settings;
290
+ env?: string;
291
+ is_active?: boolean;
292
+ is_public?: boolean;
293
+ icon?: string;
294
+ template_component_id?: string;
295
+ integrator?: string;
296
+ };
297
+ type ComponentCreateResponse = ComponentListItem;
298
+ export { FindParams, FindOptions, FindResponse, FindAdvancedParams, FindAggregateParams, Model, UpdateOptions, ModifyOptions, ComponentOptions, ComponentListResponse, ComponentListItem, ComponentLabel, ComponentWorkspace, StreamCallback, StreamHandler, AggregateChainable, UpdateManyOptions, CreateManyOptions, Settings, SettingsField, FieldRoles, FieldConstraints, Context, Preset, PresetContext, Filters, Function, TemplatesDist, SetupData, ComponentCreateResponse, };
@@ -19008,28 +19008,28 @@ class PlatformBaseClient extends BaseClient {
19008
19008
  let { env = null, token = null, host = null, } = options !== null && options !== void 0 ? options : {};
19009
19009
  let headers = {};
19010
19010
  var project_uuid = null;
19011
- if (isBrowser) {
19012
- if (sessionStorage.getItem('protokol_context') == "forge") {
19013
- headers['X-Project-Env'] = (_a = sessionStorage.getItem('forge_app_env')) !== null && _a !== void 0 ? _a : "dev";
19014
- }
19015
- else {
19016
- headers['X-Project-Env'] = (_b = localStorage.getItem('current_env')) !== null && _b !== void 0 ? _b : "dev";
19017
- }
19018
- }
19019
- else if (isNode) {
19020
- host = (_c = host !== null && host !== void 0 ? host : process.env.API_HOST) !== null && _c !== void 0 ? _c : null;
19021
- env = (_d = env !== null && env !== void 0 ? env : process.env.PROJECT_ENV) !== null && _d !== void 0 ? _d : null;
19022
- token = (_e = token !== null && token !== void 0 ? token : process.env.PROJECT_API_TOKEN) !== null && _e !== void 0 ? _e : null;
19023
- project_uuid = (_f = process.env.PROJECT_UUID) !== null && _f !== void 0 ? _f : null;
19024
- }
19025
- else if (isSandbox) {
19011
+ if (isBrowser || isSandbox) {
19026
19012
  // @ts-ignore
19027
19013
  const __global_env__ = window === null || window === void 0 ? void 0 : window.__ENV_VARIABLES__;
19028
- host = (_g = __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.API_HOST) !== null && _g !== void 0 ? _g : host;
19014
+ host = (_a = __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.API_HOST) !== null && _a !== void 0 ? _a : host;
19029
19015
  // @ts-ignore
19030
19016
  env = env !== null && env !== void 0 ? env : __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_ENV;
19031
19017
  token = token !== null && token !== void 0 ? token : __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_API_TOKEN;
19032
19018
  project_uuid = __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_UUID;
19019
+ if (isBrowser) {
19020
+ if (sessionStorage.getItem('protokol_context') == "forge") {
19021
+ headers['X-Project-Env'] = (_b = sessionStorage.getItem('forge_app_env')) !== null && _b !== void 0 ? _b : "dev";
19022
+ }
19023
+ else {
19024
+ headers['X-Project-Env'] = (_c = localStorage.getItem('current_env')) !== null && _c !== void 0 ? _c : "dev";
19025
+ }
19026
+ }
19027
+ }
19028
+ else if (isNode) {
19029
+ host = (_d = host !== null && host !== void 0 ? host : process.env.API_HOST) !== null && _d !== void 0 ? _d : null;
19030
+ env = (_e = env !== null && env !== void 0 ? env : process.env.PROJECT_ENV) !== null && _e !== void 0 ? _e : null;
19031
+ token = (_f = token !== null && token !== void 0 ? token : process.env.PROJECT_API_TOKEN) !== null && _f !== void 0 ? _f : null;
19032
+ project_uuid = (_g = process.env.PROJECT_UUID) !== null && _g !== void 0 ? _g : null;
19033
19033
  }
19034
19034
  if (token) {
19035
19035
  headers['Authorization'] = `Bearer ${token}`;
@@ -20208,27 +20208,27 @@ class IntegrationsBaseClient extends BaseClient {
20208
20208
  let { env = null, token = null, host = null, } = options !== null && options !== void 0 ? options : {};
20209
20209
  let headers = {};
20210
20210
  var project_uuid = null;
20211
- if (isBrowser) {
20212
- if (sessionStorage.getItem('protokol_context') == "forge") {
20213
- headers['X-Project-Env'] = (_a = sessionStorage.getItem('forge_app_env')) !== null && _a !== void 0 ? _a : "dev";
20214
- }
20215
- else {
20216
- headers['X-Project-Env'] = (_b = localStorage.getItem('current_env')) !== null && _b !== void 0 ? _b : "dev";
20217
- }
20218
- }
20219
- else if (isNode) {
20220
- host = (_c = host !== null && host !== void 0 ? host : process.env.API_HOST) !== null && _c !== void 0 ? _c : null;
20221
- env = (_d = env !== null && env !== void 0 ? env : process.env.PROJECT_ENV) !== null && _d !== void 0 ? _d : null;
20222
- token = (_e = token !== null && token !== void 0 ? token : process.env.PROJECT_API_TOKEN) !== null && _e !== void 0 ? _e : null;
20223
- project_uuid = (_f = process.env.PROJECT_UUID) !== null && _f !== void 0 ? _f : null;
20224
- }
20225
- else if (isSandbox) {
20211
+ if (isBrowser || isSandbox) {
20226
20212
  // @ts-ignore
20227
20213
  const __global_env__ = window === null || window === void 0 ? void 0 : window.__ENV_VARIABLES__;
20228
- host = (_g = __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.API_HOST) !== null && _g !== void 0 ? _g : host;
20214
+ host = (_a = __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.INTEGRATION_API) !== null && _a !== void 0 ? _a : host;
20229
20215
  // @ts-ignore
20230
20216
  env = env !== null && env !== void 0 ? env : __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_ENV;
20231
20217
  token = token !== null && token !== void 0 ? token : __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_API_TOKEN;
20218
+ if (isBrowser) {
20219
+ if (sessionStorage.getItem('protokol_context') == "forge") {
20220
+ headers['X-Project-Env'] = (_b = sessionStorage.getItem('forge_app_env')) !== null && _b !== void 0 ? _b : "dev";
20221
+ }
20222
+ else {
20223
+ headers['X-Project-Env'] = (_c = localStorage.getItem('current_env')) !== null && _c !== void 0 ? _c : "dev";
20224
+ }
20225
+ }
20226
+ }
20227
+ else if (isNode) {
20228
+ host = (_d = host !== null && host !== void 0 ? host : process.env.INTEGRATION_API) !== null && _d !== void 0 ? _d : null;
20229
+ env = (_e = env !== null && env !== void 0 ? env : process.env.PROJECT_ENV) !== null && _e !== void 0 ? _e : null;
20230
+ token = (_f = token !== null && token !== void 0 ? token : process.env.PROJECT_API_TOKEN) !== null && _f !== void 0 ? _f : null;
20231
+ project_uuid = (_g = process.env.PROJECT_UUID) !== null && _g !== void 0 ? _g : null;
20232
20232
  }
20233
20233
  if (token) {
20234
20234
  headers['Authorization'] = `Bearer ${token}`;
@@ -39,28 +39,28 @@ class PlatformBaseClient extends BaseClient {
39
39
  let { env = null, token = null, host = null, } = options !== null && options !== void 0 ? options : {};
40
40
  let headers = {};
41
41
  var project_uuid = null;
42
- if (isBrowser) {
43
- if (sessionStorage.getItem('protokol_context') == "forge") {
44
- headers['X-Project-Env'] = (_a = sessionStorage.getItem('forge_app_env')) !== null && _a !== void 0 ? _a : "dev";
45
- }
46
- else {
47
- headers['X-Project-Env'] = (_b = localStorage.getItem('current_env')) !== null && _b !== void 0 ? _b : "dev";
48
- }
49
- }
50
- else if (isNode) {
51
- host = (_c = host !== null && host !== void 0 ? host : process.env.API_HOST) !== null && _c !== void 0 ? _c : null;
52
- env = (_d = env !== null && env !== void 0 ? env : process.env.PROJECT_ENV) !== null && _d !== void 0 ? _d : null;
53
- token = (_e = token !== null && token !== void 0 ? token : process.env.PROJECT_API_TOKEN) !== null && _e !== void 0 ? _e : null;
54
- project_uuid = (_f = process.env.PROJECT_UUID) !== null && _f !== void 0 ? _f : null;
55
- }
56
- else if (isSandbox) {
42
+ if (isBrowser || isSandbox) {
57
43
  // @ts-ignore
58
44
  const __global_env__ = window === null || window === void 0 ? void 0 : window.__ENV_VARIABLES__;
59
- host = (_g = __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.API_HOST) !== null && _g !== void 0 ? _g : host;
45
+ host = (_a = __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.API_HOST) !== null && _a !== void 0 ? _a : host;
60
46
  // @ts-ignore
61
47
  env = env !== null && env !== void 0 ? env : __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_ENV;
62
48
  token = token !== null && token !== void 0 ? token : __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_API_TOKEN;
63
49
  project_uuid = __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_UUID;
50
+ if (isBrowser) {
51
+ if (sessionStorage.getItem('protokol_context') == "forge") {
52
+ headers['X-Project-Env'] = (_b = sessionStorage.getItem('forge_app_env')) !== null && _b !== void 0 ? _b : "dev";
53
+ }
54
+ else {
55
+ headers['X-Project-Env'] = (_c = localStorage.getItem('current_env')) !== null && _c !== void 0 ? _c : "dev";
56
+ }
57
+ }
58
+ }
59
+ else if (isNode) {
60
+ host = (_d = host !== null && host !== void 0 ? host : process.env.API_HOST) !== null && _d !== void 0 ? _d : null;
61
+ env = (_e = env !== null && env !== void 0 ? env : process.env.PROJECT_ENV) !== null && _e !== void 0 ? _e : null;
62
+ token = (_f = token !== null && token !== void 0 ? token : process.env.PROJECT_API_TOKEN) !== null && _f !== void 0 ? _f : null;
63
+ project_uuid = (_g = process.env.PROJECT_UUID) !== null && _g !== void 0 ? _g : null;
64
64
  }
65
65
  if (token) {
66
66
  headers['Authorization'] = `Bearer ${token}`;
@@ -1239,27 +1239,27 @@ class IntegrationsBaseClient extends BaseClient {
1239
1239
  let { env = null, token = null, host = null, } = options !== null && options !== void 0 ? options : {};
1240
1240
  let headers = {};
1241
1241
  var project_uuid = null;
1242
- if (isBrowser) {
1243
- if (sessionStorage.getItem('protokol_context') == "forge") {
1244
- headers['X-Project-Env'] = (_a = sessionStorage.getItem('forge_app_env')) !== null && _a !== void 0 ? _a : "dev";
1245
- }
1246
- else {
1247
- headers['X-Project-Env'] = (_b = localStorage.getItem('current_env')) !== null && _b !== void 0 ? _b : "dev";
1248
- }
1249
- }
1250
- else if (isNode) {
1251
- host = (_c = host !== null && host !== void 0 ? host : process.env.API_HOST) !== null && _c !== void 0 ? _c : null;
1252
- env = (_d = env !== null && env !== void 0 ? env : process.env.PROJECT_ENV) !== null && _d !== void 0 ? _d : null;
1253
- token = (_e = token !== null && token !== void 0 ? token : process.env.PROJECT_API_TOKEN) !== null && _e !== void 0 ? _e : null;
1254
- project_uuid = (_f = process.env.PROJECT_UUID) !== null && _f !== void 0 ? _f : null;
1255
- }
1256
- else if (isSandbox) {
1242
+ if (isBrowser || isSandbox) {
1257
1243
  // @ts-ignore
1258
1244
  const __global_env__ = window === null || window === void 0 ? void 0 : window.__ENV_VARIABLES__;
1259
- host = (_g = __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.API_HOST) !== null && _g !== void 0 ? _g : host;
1245
+ host = (_a = __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.INTEGRATION_API) !== null && _a !== void 0 ? _a : host;
1260
1246
  // @ts-ignore
1261
1247
  env = env !== null && env !== void 0 ? env : __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_ENV;
1262
1248
  token = token !== null && token !== void 0 ? token : __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_API_TOKEN;
1249
+ if (isBrowser) {
1250
+ if (sessionStorage.getItem('protokol_context') == "forge") {
1251
+ headers['X-Project-Env'] = (_b = sessionStorage.getItem('forge_app_env')) !== null && _b !== void 0 ? _b : "dev";
1252
+ }
1253
+ else {
1254
+ headers['X-Project-Env'] = (_c = localStorage.getItem('current_env')) !== null && _c !== void 0 ? _c : "dev";
1255
+ }
1256
+ }
1257
+ }
1258
+ else if (isNode) {
1259
+ host = (_d = host !== null && host !== void 0 ? host : process.env.INTEGRATION_API) !== null && _d !== void 0 ? _d : null;
1260
+ env = (_e = env !== null && env !== void 0 ? env : process.env.PROJECT_ENV) !== null && _e !== void 0 ? _e : null;
1261
+ token = (_f = token !== null && token !== void 0 ? token : process.env.PROJECT_API_TOKEN) !== null && _f !== void 0 ? _f : null;
1262
+ project_uuid = (_g = process.env.PROJECT_UUID) !== null && _g !== void 0 ? _g : null;
1263
1263
  }
1264
1264
  if (token) {
1265
1265
  headers['Authorization'] = `Bearer ${token}`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ptkl/sdk",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "scripts": {
5
5
  "build": "rollup -c",
6
6
  "build:monaco": "npm run build && node scripts/generate-monaco-types.cjs",