@prismatic-io/prism 7.3.1-rc.0 → 7.3.1-rc.1

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/lib/index.js CHANGED
@@ -64899,7 +64899,7 @@ To test the component, run "npm run test" or "yarn test"
64899
64899
  To build the component, run "npm run build" or "yarn build"
64900
64900
  To publish the component, run "prism components:publish"
64901
64901
 
64902
- For documentation on writing custom components, visit https://prismatic.io/docs/custom-components/writing-custom-components/
64902
+ For documentation on writing custom components, visit https://prismatic.io/docs/custom-connectors/
64903
64903
  `)}static async invoke(e,n){await MVe.run(Nze(e),n)}}class fet extends XEe.Command{static description="Initialize a new Component";static flags={"wsdl-path":XEe.Flags.string({required:!1,description:"Path to the WSDL definition file used to generate a Component"}),"open-api-path":XEe.Flags.string({required:!1,description:"The path to an OpenAPI Specification file (JSON or YAML) used to generate a Component"}),verbose:XEe.Flags.boolean({required:!1,default:!1,description:"Output more verbose logging from Component generation"})};static args={name:XEe.Args.string({required:!0,description:"Name of the new component to create (alphanumeric characters, hyphens, and underscores)"})};async run(){let e=process.cwd();try{let{args:{name:n},flags:{verbose:o,"wsdl-path":c,"open-api-path":p}}=await this.parse(fet),g=c?zMe.resolve(c):void 0,T=p?zMe.resolve(p):void 0;if(!qWe.test(n))this.error(`'${n}' contains invalid characters. Please select a component name that starts and ends with alphanumeric characters, and contains only alphanumeric characters, hyphens, and underscores. See https://regex101.com/?regex=${encodeURIComponent(qWe.source)}`,{exit:1});if(g&&!g?.includes(".wsdl"))this.error("If a WSDL is provided it must have an extension of '.wsdl'",{exit:1});if(this.log(`Creating component directory for "${n}"...`),await G7u.mkdir(n),process.chdir(n),T)await MVe.invoke({name:n,openapi:T},this.config);else if(await C9e.invoke({name:n,description:"Prism-generated Component"},this.config),process.chdir(e),g){if(!o)AVi.Logger.disabled();let[I]=zMe.basename(g).split(".wsdl");await SVi.parseAndGenerate(g,n,{caseInsensitiveNames:!0}),await $Ei({projectRoot:n,projectTemplateName:I,projectTemplatePath:g})}process.chdir(zMe.join(e,n)),await Pze({path:"package.json",scripts:{build:"webpack",publish:"npm run build && prism components:publish","generate:manifest":"npm run build && npx @prismatic-io/spectral component-manifest","generate:manifest:dev":"npm run build && npx @prismatic-io/spectral component-manifest --skip-signature-verify",test:"jest",lint:"eslint --ext .ts ."},eslintConfig:{root:!0,extends:["@prismatic-io/eslint-config-spectral"]},dependencies:{"@prismatic-io/spectral":"*",...g?{soap:"1.1.10"}:{}},devDependencies:W4t});let N=await u3t(n);await s3t(n,N),this.log(`
64904
64904
  "${n}" is ready for development.
64905
64905
  To install dependencies, run either "npm install" or "yarn install"
@@ -65286,7 +65286,7 @@ To run unit tests for the integration, run "npm run test" or "yarn test"
65286
65286
  To build the integration, run "npm run build" or "yarn build"
65287
65287
  To import the integration, run "prism integrations:import"
65288
65288
 
65289
- For documentation on writing code-native integrations, visit https://prismatic.io/docs/code-native-integrations/
65289
+ For documentation on writing code-native integrations, visit https://prismatic.io/docs/integrations/code-native/
65290
65290
  `)}}var VMe=Qm(zE(),1);class Wet extends Ag{static description="List Integration versions";static flags={...VMe.ux.table.flags(),"latest-available":VMe.Flags.boolean({char:"l",description:"Show only the latest available version"})};static args={integration:VMe.Args.string({required:!0,description:"ID of an integration"})};async run(){let{flags:e,args:{integration:n}}=await this.parse(Wet),o=await km({document:bm`
65291
65291
  query listIntegrationVersions(
65292
65292
  $integrationId: ID!
@@ -10,40 +10,39 @@
10
10
  * https://prismatic.io/docs/custom-connectors/unit-testing/
11
11
  */
12
12
 
13
- import {
14
- createConnection,
15
- createHarness,
16
- } from "@prismatic-io/spectral/dist/testing";
13
+ import { createConnection, createHarness } from "@prismatic-io/spectral/dist/testing";
17
14
  import myComponent from ".";
18
- import { apiKeyConnection } from "./connections";
15
+ import { acmeApiKey } from "./connections";
19
16
 
20
17
  const harness = createHarness(myComponent);
21
18
 
22
- const acmeConnection = createConnection(apiKeyConnection, {
19
+ const acmeConnection = createConnection(acmeApiKey, {
23
20
  baseUrl: "https://my-json-server.typicode.com/prismatic-io/placeholder-data",
24
21
  apiKey: "P@s$W0rD",
25
22
  });
26
23
 
24
+ const expectedItems = [
25
+ {
26
+ id: 1,
27
+ name: "Widgets",
28
+ quantity: 20,
29
+ },
30
+ {
31
+ id: 2,
32
+ name: "Whatsits",
33
+ quantity: 100,
34
+ },
35
+ {
36
+ id: 3,
37
+ name: "Gadgets",
38
+ quantity: 5,
39
+ },
40
+ ];
41
+
27
42
  describe("Test Actions", () => {
28
43
  test("Verify listItems returns the correct number of items", async () => {
29
44
  const result = await harness.action("listItems", { acmeConnection });
30
- expect(result?.data).toStrictEqual([
31
- {
32
- id: 1,
33
- name: "Widgets",
34
- quantity: 20,
35
- },
36
- {
37
- id: 2,
38
- name: "Whatsits",
39
- quantity: 100,
40
- },
41
- {
42
- id: 3,
43
- name: "Gadgets",
44
- quantity: 5,
45
- },
46
- ]);
45
+ expect(result?.data).toStrictEqual(expectedItems);
47
46
  });
48
47
 
49
48
  test("Verify getItem returns the correct item", async () => {
@@ -51,11 +50,7 @@ describe("Test Actions", () => {
51
50
  acmeConnection,
52
51
  itemId: "3",
53
52
  });
54
- expect(result?.data).toStrictEqual({
55
- id: 3,
56
- name: "Gadgets",
57
- quantity: 5,
58
- });
53
+ expect(result?.data).toStrictEqual(expectedItems[2]);
59
54
  });
60
55
 
61
56
  test("Verify addItem adds an item to inventory", async () => {
@@ -66,4 +61,15 @@ describe("Test Actions", () => {
66
61
  });
67
62
  expect(result?.data).toMatchObject({ name: "My New Item", quantity: 50 });
68
63
  });
64
+
65
+ test("Verify raw request works as expected", async () => {
66
+ const result = await harness.action("rawRequest", {
67
+ acmeConnection,
68
+ url: "/items",
69
+ method: "get",
70
+ responseType: "json",
71
+ queryParams: [{ key: "id", value: "2" }],
72
+ });
73
+ expect(result?.data).toStrictEqual([expectedItems[1]]);
74
+ });
69
75
  });
@@ -9,6 +9,10 @@
9
9
  */
10
10
 
11
11
  import { action, input, util } from "@prismatic-io/spectral";
12
+ import {
13
+ inputs as httpClientInputs,
14
+ sendRawRequest,
15
+ } from "@prismatic-io/spectral/dist/clients/http";
12
16
  import { createAcmeClient } from "./client";
13
17
 
14
18
  interface Item {
@@ -124,4 +128,30 @@ const addItem = action({
124
128
  },
125
129
  });
126
130
 
127
- export default { addItem, getItem, listItems };
131
+ const rawRequest = action({
132
+ display: {
133
+ label: "Raw Request",
134
+ description: "Send an HTTP request to any Acme endpoint",
135
+ },
136
+ inputs: {
137
+ acmeConnection: connectionInput,
138
+ ...httpClientInputs,
139
+ url: {
140
+ // Optional; this adds component-specific instructions to the URL input
141
+ ...httpClientInputs.url,
142
+ comments:
143
+ "The base URL from your connection is already included (https://my-json-server.typicode.com/prismatic-io/placeholder-data). For example, to connect to https://my-json-server.typicode.com/prismatic-io/placeholder-data/items, only /items is entered in this field.",
144
+ example: "/items",
145
+ },
146
+ },
147
+ perform: async (context, { acmeConnection, ...httpClientInputs }) => {
148
+ const { data } = await sendRawRequest(
149
+ util.types.toString(acmeConnection.fields.baseUrl),
150
+ httpClientInputs,
151
+ { Authorization: `Bearer ${acmeConnection.fields.apiKey}` }, // Authorization methods vary by API
152
+ );
153
+ return { data };
154
+ },
155
+ });
156
+
157
+ export default { addItem, getItem, listItems, rawRequest };
@@ -13,7 +13,7 @@
13
13
 
14
14
  import { connection } from "@prismatic-io/spectral";
15
15
 
16
- export const apiKeyConnection = connection({
16
+ export const acmeApiKey = connection({
17
17
  key: "apiKey",
18
18
  display: {
19
19
  label: "Acme Connection",
@@ -24,8 +24,7 @@ export const apiKeyConnection = connection({
24
24
  label: "Acme Base URL",
25
25
  type: "string",
26
26
  required: true,
27
- default:
28
- "https://my-json-server.typicode.com/prismatic-io/placeholder-data",
27
+ default: "https://my-json-server.typicode.com/prismatic-io/placeholder-data",
29
28
  example: "https://my-company.api.acme.com/",
30
29
  },
31
30
  apiKey: {
@@ -38,4 +37,4 @@ export const apiKeyConnection = connection({
38
37
  },
39
38
  });
40
39
 
41
- export default [apiKeyConnection];
40
+ export default [acmeApiKey];
@@ -9,16 +9,13 @@
9
9
  * https://prismatic.io/docs/custom-connectors/unit-testing/
10
10
  */
11
11
 
12
- import {
13
- createConnection,
14
- createHarness,
15
- } from "@prismatic-io/spectral/dist/testing";
12
+ import { createConnection, createHarness } from "@prismatic-io/spectral/dist/testing";
16
13
  import myComponent from ".";
17
- import { apiKeyConnection } from "./connections";
14
+ import { acmeApiKey } from "./connections";
18
15
 
19
16
  const harness = createHarness(myComponent);
20
17
 
21
- const acmeConnection = createConnection(apiKeyConnection, {
18
+ const acmeConnection = createConnection(acmeApiKey, {
22
19
  baseUrl: "https://my-json-server.typicode.com/prismatic-io/placeholder-data",
23
20
  apiKey: "P@s$W0rD",
24
21
  });
@@ -24,8 +24,7 @@ interface Item {
24
24
  export const selectItem = dataSource({
25
25
  display: {
26
26
  label: "Select Item",
27
- description:
28
- "This data source fetches a list of items, and presents them as a dropdown menu",
27
+ description: "This data source fetches a list of items, and presents them as a dropdown menu",
29
28
  },
30
29
  dataSourceType: "picklist",
31
30
  inputs: {
@@ -15,11 +15,11 @@ import {
15
15
  defaultTriggerPayload,
16
16
  } from "@prismatic-io/spectral/dist/testing";
17
17
  import myComponent from ".";
18
- import { apiKeyConnection } from "./connections";
18
+ import { acmeApiKey } from "./connections";
19
19
 
20
20
  const harness = createHarness(myComponent);
21
21
 
22
- const acmeConnection = createConnection(apiKeyConnection, {
22
+ const acmeConnection = createConnection(acmeApiKey, {
23
23
  baseUrl: "https://my-json-server.typicode.com/prismatic-io/placeholder-data",
24
24
  apiKey: "P@s$W0rD",
25
25
  });
@@ -37,9 +37,7 @@ describe("Test Trigger", () => {
37
37
  acmeConnection,
38
38
  });
39
39
 
40
- expect(result?.payload.rawBody.data).toEqual(
41
- JSON.stringify({ foo: "bar", baz: "buz" })
42
- );
40
+ expect(result?.payload.rawBody.data).toEqual(JSON.stringify({ foo: "bar", baz: "buz" }));
43
41
  });
44
42
 
45
43
  test("Test invalid HMAC signature", async () => {
@@ -24,9 +24,7 @@ export const exampleTrigger = trigger({
24
24
  }),
25
25
  },
26
26
  perform: async (context, payload, params) => {
27
- const hmacSecretKey = util.types.toString(
28
- params.acmeConnection.fields.apiKey
29
- );
27
+ const hmacSecretKey = util.types.toString(params.acmeConnection.fields.apiKey);
30
28
  const { "x-hmac-256": hmacSignature } = payload.headers;
31
29
 
32
30
  // Compute the HMAC hash of the request using the connection's API key
@@ -1,37 +1,37 @@
1
1
  import type { ComponentManifest, ConfigPage, ScopedConfigVar } from "@prismatic-io/spectral";
2
2
 
3
3
  // @ts-ignore
4
- import type { configPages, componentRegistry, userLevelConfigPages, scopedConfigVars } from "../src";
4
+ import type {
5
+ configPages,
6
+ componentRegistry,
7
+ userLevelConfigPages,
8
+ scopedConfigVars,
9
+ } from "../src";
5
10
 
6
11
  type IsAny<T> = 0 extends 1 & T ? true : false;
7
12
 
8
- type TConfigPages =
9
- IsAny<typeof configPages> extends true
10
- ? { [key: string]: ConfigPage }
11
- : typeof configPages;
13
+ type TConfigPages = IsAny<typeof configPages> extends true
14
+ ? { [key: string]: ConfigPage }
15
+ : typeof configPages;
12
16
 
13
- type TUserLevelConfigPages =
14
- IsAny<typeof userLevelConfigPages> extends true
15
- ? { [key: string]: ConfigPage }
16
- : typeof userLevelConfigPages;
17
+ type TUserLevelConfigPages = IsAny<typeof userLevelConfigPages> extends true
18
+ ? { [key: string]: ConfigPage }
19
+ : typeof userLevelConfigPages;
17
20
 
18
- type TComponentRegistry =
19
- IsAny<typeof componentRegistry> extends true
20
- ? { [key: string]: ComponentManifest }
21
- : typeof componentRegistry;
21
+ type TComponentRegistry = IsAny<typeof componentRegistry> extends true
22
+ ? { [key: string]: ComponentManifest }
23
+ : typeof componentRegistry;
22
24
 
23
- type TScopedConfigVarMap =
24
- IsAny<typeof scopedConfigVars> extends true
25
- ? { [key: string]: ScopedConfigVar }
26
- : typeof scopedConfigVars;
25
+ type TScopedConfigVarMap = IsAny<typeof scopedConfigVars> extends true
26
+ ? { [key: string]: ScopedConfigVar }
27
+ : typeof scopedConfigVars;
27
28
 
28
29
  declare module "@prismatic-io/spectral" {
29
30
  // eslint-disable-next-line @typescript-eslint/no-empty-interface
30
31
  interface IntegrationDefinitionConfigPages extends TConfigPages {}
31
32
 
32
33
  // eslint-disable-next-line @typescript-eslint/no-empty-interface
33
- interface IntegrationDefinitionUserLevelConfigPages
34
- extends TUserLevelConfigPages {}
34
+ interface IntegrationDefinitionUserLevelConfigPages extends TUserLevelConfigPages {}
35
35
 
36
36
  // eslint-disable-next-line @typescript-eslint/no-empty-interface
37
37
  interface IntegrationDefinitionComponentRegistry extends TComponentRegistry {}
@@ -39,4 +39,3 @@ declare module "@prismatic-io/spectral" {
39
39
  // eslint-disable-next-line @typescript-eslint/no-empty-interface
40
40
  interface IntegrationDefinitionScopedConfigVars extends TScopedConfigVarMap {}
41
41
  }
42
-
@@ -36,8 +36,7 @@ export const configPages = {
36
36
  label: "Acme Base URL",
37
37
  type: "string",
38
38
  required: true,
39
- default:
40
- "https://my-json-server.typicode.com/prismatic-io/placeholder-data",
39
+ default: "https://my-json-server.typicode.com/prismatic-io/placeholder-data",
41
40
  example: "https://my-company.api.acme.com/",
42
41
  },
43
42
  apiKey: {
@@ -62,9 +61,7 @@ export const configPages = {
62
61
  dataSourceType: "picklist",
63
62
  perform: async (context) => {
64
63
  // Create an authenticated reusable HTTP client from client.ts
65
- const client = createAcmeClient(
66
- context.configVars["Acme Connection"] as Connection
67
- );
64
+ const client = createAcmeClient(context.configVars["Acme Connection"] as Connection);
68
65
  const { data: items } = await client.get<Item[]>("/items");
69
66
  const options: Element[] = items.map((item) => ({
70
67
  key: `${item.id}`,
@@ -14,8 +14,7 @@ import { listItems } from "./flows";
14
14
 
15
15
  const acmeConnection = {
16
16
  fields: {
17
- baseUrl:
18
- "https://my-json-server.typicode.com/prismatic-io/placeholder-data",
17
+ baseUrl: "https://my-json-server.typicode.com/prismatic-io/placeholder-data",
19
18
  apiKey: "P@s$W0rD",
20
19
  },
21
20
  };
@@ -37,10 +36,8 @@ describe("Verify flow works as expected", () => {
37
36
  configVars: { "Acme Connection": acmeConnection, "Select Item": "2" },
38
37
  });
39
38
  expect(loggerMock.info).toHaveBeenCalledWith(
40
- 'During configuration, the customer selected the item "2"'
41
- );
42
- expect(loggerMock.info).toHaveBeenCalledWith(
43
- 'Item "Widgets" with ID "1" has quantity "20"'
39
+ 'During configuration, the customer selected the item "2"',
44
40
  );
41
+ expect(loggerMock.info).toHaveBeenCalledWith('Item "Widgets" with ID "1" has quantity "20"');
45
42
  });
46
43
  });
@@ -26,21 +26,19 @@ export const listItems = flow({
26
26
  },
27
27
  onExecution: async (context, params) => {
28
28
  context.logger.info(
29
- `During configuration, the customer selected the item "${context.configVars["Select Item"]}"`
29
+ `During configuration, the customer selected the item "${context.configVars["Select Item"]}"`,
30
30
  );
31
31
 
32
32
  // Create an authenticated reusable HTTP client from client.ts
33
- const acmeErpClient = createAcmeClient(
34
- context.configVars["Acme Connection"] as Connection
35
- );
33
+ const acmeErpClient = createAcmeClient(context.configVars["Acme Connection"] as Connection);
36
34
  const response = await acmeErpClient.get<Item[]>("/items");
37
35
  for (const item of response.data) {
38
36
  context.logger.info(
39
- `Item "${item.name}" with ID "${item.id}" has quantity "${item.quantity}"`
37
+ `Item "${item.name}" with ID "${item.id}" has quantity "${item.quantity}"`,
40
38
  );
41
39
  }
42
40
  return { data: response.data };
43
41
  },
44
42
  });
45
43
 
46
- export default [listItems];
44
+ export default [listItems];
@@ -1,37 +1,37 @@
1
1
  import type { ComponentManifest, ConfigPage, ScopedConfigVar } from "@prismatic-io/spectral";
2
2
 
3
3
  // @ts-ignore
4
- import type { configPages, componentRegistry, userLevelConfigPages, scopedConfigVars } from "../src";
4
+ import type {
5
+ configPages,
6
+ componentRegistry,
7
+ userLevelConfigPages,
8
+ scopedConfigVars,
9
+ } from "../src";
5
10
 
6
11
  type IsAny<T> = 0 extends 1 & T ? true : false;
7
12
 
8
- type TConfigPages =
9
- IsAny<typeof configPages> extends true
10
- ? { [key: string]: ConfigPage }
11
- : typeof configPages;
13
+ type TConfigPages = IsAny<typeof configPages> extends true
14
+ ? { [key: string]: ConfigPage }
15
+ : typeof configPages;
12
16
 
13
- type TUserLevelConfigPages =
14
- IsAny<typeof userLevelConfigPages> extends true
15
- ? { [key: string]: ConfigPage }
16
- : typeof userLevelConfigPages;
17
+ type TUserLevelConfigPages = IsAny<typeof userLevelConfigPages> extends true
18
+ ? { [key: string]: ConfigPage }
19
+ : typeof userLevelConfigPages;
17
20
 
18
- type TComponentRegistry =
19
- IsAny<typeof componentRegistry> extends true
20
- ? { [key: string]: ComponentManifest }
21
- : typeof componentRegistry;
21
+ type TComponentRegistry = IsAny<typeof componentRegistry> extends true
22
+ ? { [key: string]: ComponentManifest }
23
+ : typeof componentRegistry;
22
24
 
23
- type TScopedConfigVarMap =
24
- IsAny<typeof scopedConfigVars> extends true
25
- ? { [key: string]: ScopedConfigVar }
26
- : typeof scopedConfigVars;
25
+ type TScopedConfigVarMap = IsAny<typeof scopedConfigVars> extends true
26
+ ? { [key: string]: ScopedConfigVar }
27
+ : typeof scopedConfigVars;
27
28
 
28
29
  declare module "@prismatic-io/spectral" {
29
30
  // eslint-disable-next-line @typescript-eslint/no-empty-interface
30
31
  interface IntegrationDefinitionConfigPages extends TConfigPages {}
31
32
 
32
33
  // eslint-disable-next-line @typescript-eslint/no-empty-interface
33
- interface IntegrationDefinitionUserLevelConfigPages
34
- extends TUserLevelConfigPages {}
34
+ interface IntegrationDefinitionUserLevelConfigPages extends TUserLevelConfigPages {}
35
35
 
36
36
  // eslint-disable-next-line @typescript-eslint/no-empty-interface
37
37
  interface IntegrationDefinitionComponentRegistry extends TComponentRegistry {}
@@ -39,4 +39,3 @@ declare module "@prismatic-io/spectral" {
39
39
  // eslint-disable-next-line @typescript-eslint/no-empty-interface
40
40
  interface IntegrationDefinitionScopedConfigVars extends TScopedConfigVarMap {}
41
41
  }
42
-
@@ -5346,5 +5346,5 @@
5346
5346
  "enableJsonFlag": false
5347
5347
  }
5348
5348
  },
5349
- "version": "7.3.1-rc.0"
5349
+ "version": "7.3.1-rc.1"
5350
5350
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prismatic-io/prism",
3
- "version": "7.3.1-rc.0",
3
+ "version": "7.3.1-rc.1",
4
4
  "description": "Build, deploy, and support integrations in Prismatic from the comfort of your command line",
5
5
  "keywords": ["prismatic", "cli"],
6
6
  "homepage": "https://prismatic.io",