@ptkl/sdk 0.2.1 → 0.2.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.
@@ -1,6 +1,6 @@
1
- import BaseClient from "./baseClient";
2
- export default class APIUser extends BaseClient {
3
- apiAuth(username: string, password: string): Promise<import("axios").AxiosResponse<any, any>>;
1
+ import PlatformBaseClient from "./platformBaseClient";
2
+ export default class APIUser extends PlatformBaseClient {
3
+ auth(username: string, password: string, project: string): Promise<import("axios").AxiosResponse<any, any>>;
4
4
  newSecret(uuid: string): Promise<import("axios").AxiosResponse<any, any>>;
5
5
  revokeSecret(uuid: string): Promise<import("axios").AxiosResponse<any, any>>;
6
6
  edit(uuid: string, roles: string[]): Promise<import("axios").AxiosResponse<any, any>>;
@@ -1,7 +1,7 @@
1
- import BaseClient from "./baseClient";
2
- export default class Apps extends BaseClient {
1
+ import PlatformBaseClient from "./platformBaseClient";
2
+ export default class Apps extends PlatformBaseClient {
3
3
  private appType;
4
- constructor(client: any, appType?: string);
4
+ constructor(appType?: string);
5
5
  updateSettings(updateValues: any, ref: string): Promise<any>;
6
6
  download(ref: string, version: string): Promise<any>;
7
7
  upload(formData: FormData): Promise<any>;
@@ -2,4 +2,5 @@ import { AxiosInstance } from "axios";
2
2
  export default class BaseClient {
3
3
  client: AxiosInstance;
4
4
  constructor(client: AxiosInstance);
5
+ setClient(client: AxiosInstance): this;
5
6
  }
@@ -1,10 +1,8 @@
1
- import { FindParams, FindOptions, FindResponse, FindAdvancedParams, FindAggregateParams, Model } from "src/types/component";
2
- import BaseClient from "./baseClient";
3
- import { AxiosInstance } from "axios";
4
- export default class Component extends BaseClient {
1
+ import { FindParams, FindOptions, FindResponse, FindAdvancedParams, FindAggregateParams, Model, UpdateOptions } from "src/types/component";
2
+ import PlatformBaseClient from "./platformBaseClient";
3
+ export default class Component extends PlatformBaseClient {
5
4
  private ref;
6
- constructor(adapter: AxiosInstance, ref: string);
7
- new(ref: string): this;
5
+ constructor(ref?: string | null);
8
6
  /**
9
7
  * Find method to search for models
10
8
  *
@@ -55,17 +53,31 @@ export default class Component extends BaseClient {
55
53
  * @param data
56
54
  * @returns
57
55
  */
58
- update(uuid: string, data: Record<string, any>): Promise<unknown>;
59
- concurrentUpdate(uuid: string, version: number, data: Record<string, any>): Promise<unknown>;
60
- create(model: Record<string, any>): Promise<unknown>;
61
- delete(uuid: string): Promise<unknown>;
62
- aggregate(pipeline: FindAggregateParams): Promise<unknown>;
63
- settings(): Promise<unknown>;
64
- saveSettings(settings: any): Promise<unknown>;
56
+ update(uuid: string, data: Record<string, any>, options: UpdateOptions): Promise<any>;
57
+ /**
58
+ * Update many models
59
+ *
60
+ * @param data
61
+ * @param options
62
+ * @returns
63
+ */
64
+ updateMany(data: Record<string, any>[], options: UpdateOptions): Promise<any>;
65
+ /**
66
+ * Concurrent update model by uuid
67
+ *
68
+ * @param uuid string - The uuid of the model
69
+ * @param version number - The version of the model
70
+ * @param data
71
+ * @returns
72
+ */
73
+ concurrentUpdate(uuid: string, version: number, data: Record<string, any>, options: UpdateOptions): Promise<any>;
74
+ create(model: Record<string, any>): Promise<any>;
75
+ delete(uuid: string): Promise<any>;
76
+ aggregate(pipeline: FindAggregateParams): Promise<any>;
77
+ settings(): Promise<any>;
78
+ saveSettings(settings: any, version: string): Promise<any>;
65
79
  saveTemplatesDist(version: string, sdkVersion: string, engine: string, dist: Record<string, string>): Promise<any>;
66
- workflow(event: string, input: any): Promise<import("axios").AxiosResponse<any, any>>;
67
- function(name: string, input: any): Promise<import("axios").AxiosResponse<any, any>>;
68
- all(): Promise<any>;
69
- setup(data: any): Promise<import("axios").AxiosResponse<any, any>>;
80
+ workflow(event: string, input: any): Promise<any>;
81
+ function(name: string, input: any): Promise<any>;
70
82
  }
71
- export { FindParams, FindOptions, FindResponse, FindAdvancedParams, FindAggregateParams, Model };
83
+ export { FindParams, FindOptions, FindResponse, FindAdvancedParams, FindAggregateParams, Model, UpdateOptions, };
@@ -0,0 +1,5 @@
1
+ import PlatformBaseClient from "./platformBaseClient";
2
+ export default class ComponentUtils extends PlatformBaseClient {
3
+ list(): Promise<any>;
4
+ create(data: any): Promise<any>;
5
+ }
@@ -1,6 +1,5 @@
1
- import BaseClient from "./baseClient";
2
- export default class Forge extends BaseClient {
3
- constructor(client: any);
1
+ import PlatformBaseClient from "./platformBaseClient";
2
+ export default class Forge extends PlatformBaseClient {
4
3
  bundleUpload(buffer: Buffer): Promise<any>;
5
4
  getWorkspaceApps(): Promise<any>;
6
5
  }
@@ -1,5 +1,5 @@
1
- import BaseClient from "./baseClient";
2
- export default class Functions extends BaseClient {
1
+ import PlatformBaseClient from "./platformBaseClient";
2
+ export default class Functions extends PlatformBaseClient {
3
3
  list(): Promise<any>;
4
4
  get(ref: string): Promise<any>;
5
5
  update(uuid: string, update: any): Promise<any>;
@@ -1,5 +1,5 @@
1
- import BaseClient from "../baseClient";
2
- export default class Invoicing extends BaseClient {
1
+ import PlatformBaseClient from "../platformBaseClient";
2
+ export default class Invoicing extends PlatformBaseClient {
3
3
  getSalesInvoices(provider: string, page: number): Promise<import("axios").AxiosResponse<any, any>>;
4
4
  acceptPurchaseInvoice(provider: string, id: string, comment: string): Promise<import("axios").AxiosResponse<any, any>>;
5
5
  request(method: string, endpoint: string, params: any): Promise<import("axios").AxiosResponse<any, any>>;
@@ -1,5 +1,5 @@
1
- import BaseClient from "../baseClient";
2
- export default class Media extends BaseClient {
1
+ import IntegrationsBaseClient from "../integrationsBaseClient";
2
+ export default class Media extends IntegrationsBaseClient {
3
3
  list(data: any): Promise<import("axios").AxiosResponse<any, any>>;
4
4
  libraries(): Promise<import("axios").AxiosResponse<any, any>>;
5
5
  upload(payload: any): Promise<import("axios").AxiosResponse<any, any> | undefined>;
@@ -1,5 +1,5 @@
1
- import BaseClient from "../baseClient";
2
- export default class SerbiaUtil extends BaseClient {
1
+ import IntegrationsBaseClient from "../integrationsBaseClient";
2
+ export default class SerbiaUtil extends IntegrationsBaseClient {
3
3
  nsbSearch(params: any): Promise<import("axios").AxiosResponse<any, any>>;
4
4
  getReceiptFromUrl(url: string, source: string): Promise<import("axios").AxiosResponse<any, any>>;
5
5
  getContoList(): Promise<import("axios").AxiosResponse<any, any>>;
@@ -1,4 +1,4 @@
1
- import BaseClient from "../baseClient";
2
- export default class VPFR extends BaseClient {
1
+ import IntegrationsBaseClient from "../integrationsBaseClient";
2
+ export default class VPFR extends IntegrationsBaseClient {
3
3
  request(method: string, endpoint: string, params?: any): Promise<import("axios").AxiosResponse<any, any>>;
4
4
  }
@@ -1,8 +1,11 @@
1
- import BaseClient from "./baseClient";
2
- import { AxiosInstance } from "axios";
3
- export default class Integrations extends BaseClient {
1
+ import IntegrationsBaseClient from "./integrationsBaseClient";
2
+ export default class Integrations extends IntegrationsBaseClient {
4
3
  private integrations;
5
- constructor(adapter: AxiosInstance);
4
+ constructor(options?: {
5
+ env?: string;
6
+ token?: string;
7
+ host?: string;
8
+ });
6
9
  getSerbiaUtilities(): any;
7
10
  getMedia(): any;
8
11
  getVPFR(): any;
@@ -0,0 +1,8 @@
1
+ import BaseClient from "./baseClient";
2
+ export default class IntegrationsBaseClient extends BaseClient {
3
+ constructor(options?: {
4
+ env?: string;
5
+ token?: string;
6
+ host?: string;
7
+ });
8
+ }
@@ -5,22 +5,14 @@ import APIUser from "./apiUser";
5
5
  import Users from "./users";
6
6
  import Apps from "./apps";
7
7
  import Component from "./component";
8
- import Integration from "./integrations";
8
+ import ComponentUtils from "./componentUtils";
9
9
  import Ratchet from "./ratchet";
10
10
  import Sandbox from "./sandbox";
11
11
  import System from "./system";
12
12
  import Workflow from "./workflow";
13
13
  import Forge from "./forge";
14
- export default class Platform {
15
- private platformClient;
16
- private integrationsClient;
17
- constructor(options: {
18
- env?: string;
19
- token?: string;
20
- host?: string;
21
- integrationHost?: string;
22
- });
23
- setPlatformClient(client: AxiosInstance): void;
14
+ import PlatformBaseClient from "./platformBaseClient";
15
+ export default class Platform extends PlatformBaseClient {
24
16
  getPlatformClient(): AxiosInstance;
25
17
  getPlatformBaseURL(): string;
26
18
  apiUser(): APIUser;
@@ -30,7 +22,7 @@ export default class Platform {
30
22
  app(appType: string): Apps;
31
23
  forge(): Forge;
32
24
  component(ref: string): Component;
33
- integrations(): Integration;
25
+ componentUtils(): ComponentUtils;
34
26
  ratchet(): Ratchet;
35
27
  sandbox(): Sandbox;
36
28
  system(): System;
@@ -0,0 +1,27 @@
1
+ import BaseClient from "./baseClient";
2
+ /**
3
+ * Base client for the platform API
4
+ * Classes that extend PlatformBaseClient have intentins of only working in platform context
5
+ *
6
+ *
7
+ * @class PlatformBaseClient
8
+ * @extends BaseClient
9
+ * @constructor
10
+ * @param {AxiosInstance} [client] - The axios instance to use for the client
11
+ *
12
+ * @example
13
+ * // if sdk is used in the forge app that is running in the platform context
14
+ * const utils = new ComponentUtils()
15
+ * // this won't work outside of platform context because client needs authtorization to communicate with the API.
16
+ *
17
+ */
18
+ export default class PlatformBaseClient extends BaseClient {
19
+ protected env: string | null;
20
+ protected token: string | null;
21
+ protected host: string | null;
22
+ constructor(options?: {
23
+ env?: string;
24
+ token?: string;
25
+ host?: string;
26
+ });
27
+ }
@@ -1,4 +1,4 @@
1
- import BaseClient from "./baseClient";
2
- export default class Ratchet extends BaseClient {
1
+ import PlatformBaseClient from "./platformBaseClient";
2
+ export default class Ratchet extends PlatformBaseClient {
3
3
  query(name: string, params: any): Promise<any>;
4
4
  }
@@ -1,5 +1,5 @@
1
- import BaseClient from "./baseClient";
2
- export default class Roles extends BaseClient {
1
+ import PlatformBaseClient from "./platformBaseClient";
2
+ export default class Roles extends PlatformBaseClient {
3
3
  create(role: any): Promise<any>;
4
4
  delete(uuid: string): Promise<any>;
5
5
  list(): Promise<any>;
@@ -1,5 +1,5 @@
1
- import BaseClient from "./baseClient";
2
- export default class Sandbox extends BaseClient {
1
+ import PlatformBaseClient from "./platformBaseClient";
2
+ export default class Sandbox extends PlatformBaseClient {
3
3
  /**
4
4
  * Call the sandbox service to execute a serverless function
5
5
  *
@@ -1,4 +1,4 @@
1
- import BaseClient from "./baseClient";
2
- export default class System extends BaseClient {
1
+ import PlatformBaseClient from "./platformBaseClient";
2
+ export default class System extends PlatformBaseClient {
3
3
  resourceResolver(ref: string, resourceName: string, format?: string): Promise<any>;
4
4
  }
@@ -1,5 +1,5 @@
1
- import BaseClient from "./baseClient";
2
- export default class Thunder extends BaseClient {
1
+ import PlatformBaseClient from "./platformBaseClient";
2
+ export default class Thunder extends PlatformBaseClient {
3
3
  read(type: string, filters: any, flag: string, options?: any): Promise<any>;
4
4
  write(type: string, filters: any, d: any, flag: any): Promise<any>;
5
5
  operation(name: string, filters: any, data: any): Promise<any>;
@@ -1,5 +1,5 @@
1
- import BaseClient from "./baseClient";
2
- export default class Users extends BaseClient {
1
+ import PlatformBaseClient from "./platformBaseClient";
2
+ export default class Users extends PlatformBaseClient {
3
3
  invite(email: string, roles: string[]): Promise<import("axios").AxiosResponse<any, any>>;
4
4
  delete(uuid: string): Promise<import("axios").AxiosResponse<any, any>>;
5
5
  }
@@ -1,4 +1,4 @@
1
- import BaseClient from "./baseClient";
2
- export default class Workflow extends BaseClient {
1
+ import PlatformBaseClient from "./platformBaseClient";
2
+ export default class Workflow extends PlatformBaseClient {
3
3
  trigger(id: string, event: string, data: any): Promise<import("axios").AxiosResponse<any, any>>;
4
4
  }
@@ -1,13 +1,14 @@
1
1
  import Platform from './api/platform';
2
- export * as Component from './api/component';
3
- export * as Integration from './api/integrations';
4
- export * as Ratchet from './api/ratchet';
5
- export * as Sandbox from './api/sandbox';
6
- export * as System from './api/system';
7
- export * as Users from './api/users';
8
- export * as Functions from './api/functions';
9
- export * as APIUser from './api/apiUser';
10
- export * as Roles from './api/roles';
11
- export * as Apps from './api/apps';
12
- export * as Workflow from './api/workflow';
2
+ export { default as Component } from './api/component';
3
+ export { default as Integration } from './api/integrations';
4
+ export { default as Ratchet } from './api/ratchet';
5
+ export { default as Sandbox } from './api/sandbox';
6
+ export { default as System } from './api/system';
7
+ export { default as Users } from './api/users';
8
+ export { default as Functions } from './api/functions';
9
+ export { default as APIUser } from './api/apiUser';
10
+ export { default as Roles } from './api/roles';
11
+ export { default as Apps } from './api/apps';
12
+ export { default as Workflow } from './api/workflow';
13
+ export { default as ComponentUtils } from './api/componentUtils';
13
14
  export default Platform;
@@ -41,4 +41,7 @@ type Model = {
41
41
  deleted_by: string;
42
42
  [key: string]: any;
43
43
  };
44
- export { FindParams, FindOptions, FindResponse, FindAdvancedParams, FindAggregateParams, Model, };
44
+ type UpdateOptions = {
45
+ force_update_protected_fields: boolean;
46
+ };
47
+ export { FindParams, FindOptions, FindResponse, FindAdvancedParams, FindAggregateParams, Model, UpdateOptions };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ptkl/sdk",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "scripts": {
5
5
  "build": "rollup -c",
6
6
  "docs": "typedoc"