@or-sdk/card-templates 1.0.1-beta.493.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.
Files changed (61) hide show
  1. package/dist/cjs/CardTemplates.js +198 -0
  2. package/dist/cjs/CardTemplates.js.map +1 -0
  3. package/dist/cjs/constants.js +57 -0
  4. package/dist/cjs/constants.js.map +1 -0
  5. package/dist/cjs/index.js +21 -0
  6. package/dist/cjs/index.js.map +1 -0
  7. package/dist/cjs/types.js +3 -0
  8. package/dist/cjs/types.js.map +1 -0
  9. package/dist/cjs/utils/getGetByIdQuery.js +10 -0
  10. package/dist/cjs/utils/getGetByIdQuery.js.map +1 -0
  11. package/dist/cjs/utils/getListQuery.js +10 -0
  12. package/dist/cjs/utils/getListQuery.js.map +1 -0
  13. package/dist/cjs/utils/getNewCardTemplate.js +59 -0
  14. package/dist/cjs/utils/getNewCardTemplate.js.map +1 -0
  15. package/dist/cjs/utils/index.js +13 -0
  16. package/dist/cjs/utils/index.js.map +1 -0
  17. package/dist/esm/CardTemplates.js +125 -0
  18. package/dist/esm/CardTemplates.js.map +1 -0
  19. package/dist/esm/constants.js +105 -0
  20. package/dist/esm/constants.js.map +1 -0
  21. package/dist/esm/index.js +3 -0
  22. package/dist/esm/index.js.map +1 -0
  23. package/dist/esm/types.js +2 -0
  24. package/dist/esm/types.js.map +1 -0
  25. package/dist/esm/utils/getGetByIdQuery.js +13 -0
  26. package/dist/esm/utils/getGetByIdQuery.js.map +1 -0
  27. package/dist/esm/utils/getListQuery.js +15 -0
  28. package/dist/esm/utils/getListQuery.js.map +1 -0
  29. package/dist/esm/utils/getNewCardTemplate.js +63 -0
  30. package/dist/esm/utils/getNewCardTemplate.js.map +1 -0
  31. package/dist/esm/utils/index.js +4 -0
  32. package/dist/esm/utils/index.js.map +1 -0
  33. package/dist/types/CardTemplates.d.ts +63 -0
  34. package/dist/types/CardTemplates.d.ts.map +1 -0
  35. package/dist/types/constants.d.ts +6 -0
  36. package/dist/types/constants.d.ts.map +1 -0
  37. package/dist/types/index.d.ts +3 -0
  38. package/dist/types/index.d.ts.map +1 -0
  39. package/dist/types/types.d.ts +70 -0
  40. package/dist/types/types.d.ts.map +1 -0
  41. package/dist/types/utils/getGetByIdQuery.d.ts +5 -0
  42. package/dist/types/utils/getGetByIdQuery.d.ts.map +1 -0
  43. package/dist/types/utils/getListQuery.d.ts +5 -0
  44. package/dist/types/utils/getListQuery.d.ts.map +1 -0
  45. package/dist/types/utils/getNewCardTemplate.d.ts +52 -0
  46. package/dist/types/utils/getNewCardTemplate.d.ts.map +1 -0
  47. package/dist/types/utils/index.d.ts +4 -0
  48. package/dist/types/utils/index.d.ts.map +1 -0
  49. package/package.json +32 -0
  50. package/src/CardTemplates.ts +177 -0
  51. package/src/constants.ts +109 -0
  52. package/src/index.ts +2 -0
  53. package/src/types.ts +89 -0
  54. package/src/utils/getGetByIdQuery.ts +14 -0
  55. package/src/utils/getListQuery.ts +16 -0
  56. package/src/utils/getNewCardTemplate.ts +64 -0
  57. package/src/utils/index.ts +7 -0
  58. package/tsconfig.dev.json +8 -0
  59. package/tsconfig.esm.json +12 -0
  60. package/tsconfig.json +7 -0
  61. package/tsconfig.types.json +10 -0
@@ -0,0 +1,109 @@
1
+ export const DEFAULT_PROJECTION_LIST = [
2
+ 'id',
3
+ 'template',
4
+ 'template.category',
5
+ 'template.description',
6
+ 'template.help',
7
+ 'template.icon',
8
+ 'template.iconUrl',
9
+ 'template.implicitly',
10
+ 'template.label',
11
+ 'template.publishedBy',
12
+ 'template.tags',
13
+ 'template.type',
14
+ 'template.version',
15
+ ];
16
+
17
+ export const DEFAULT_PROJECTION_GET_LIST = [
18
+ 'id',
19
+ 'schemaVersion',
20
+ 'dateCreated',
21
+ 'dateModified',
22
+ 'data',
23
+ 'data.data',
24
+ 'data.form',
25
+ 'data.form.code',
26
+ 'data.form.data',
27
+ 'data.form.style',
28
+ 'data.form.template',
29
+ 'data.presentation',
30
+ 'data.presentation.code',
31
+ 'data.presentation.data',
32
+ 'data.presentation.style',
33
+ 'data.presentation.template',
34
+ 'data.tagIds',
35
+ 'reference',
36
+ 'reference.id',
37
+ 'reference.type',
38
+ 'template',
39
+ 'template.category',
40
+ 'template.description',
41
+ 'template.help',
42
+ 'template.icon',
43
+ 'template.iconUrl',
44
+ 'template.implicitly',
45
+ 'template.label',
46
+ 'template.publishedBy',
47
+ 'template.tags',
48
+ 'template.type',
49
+ 'template.version',
50
+ 'deletedDate @include(if: false)',
51
+ ];
52
+
53
+ export const QUERY_DOWNLOAD_TO = `mutation downloadTo($entity: TemplateType!, $data: DownloadInput!) {
54
+ downloadTo(entity: $entity, data: $data) {
55
+ ... on Card {
56
+ id
57
+ schemaVersion
58
+ dateCreated
59
+ dateModified
60
+ data {
61
+ data
62
+ form {
63
+ code
64
+ data
65
+ style
66
+ template
67
+ }
68
+ presentation {
69
+ code
70
+ data
71
+ style
72
+ template
73
+ }
74
+ tagIds
75
+ }
76
+ reference {
77
+ id
78
+ type
79
+ }
80
+ template {
81
+ category
82
+ description
83
+ help
84
+ icon
85
+ iconUrl
86
+ implicitly
87
+ label
88
+ publishedBy
89
+ tags
90
+ type
91
+ version
92
+ }
93
+ deletedDate @include(if: false)
94
+ }
95
+ }
96
+ }
97
+ `;
98
+
99
+
100
+ export const QUERY_UPGRADE = `mutation upgrade($entity: TemplateType!, $id: String!, $options: UpgradeOptions) {
101
+ upgrade(entity: $entity, id: $id, options: $options) {
102
+ ... on Card {
103
+ id
104
+ }
105
+ }
106
+ }
107
+ `;
108
+
109
+ export const ENTITY_NAME = 'CARD';
package/src/index.ts ADDED
@@ -0,0 +1,2 @@
1
+ export { CardTemplates } from './CardTemplates';
2
+ export * from './types';
package/src/types.ts ADDED
@@ -0,0 +1,89 @@
1
+ import { Token } from '@or-sdk/base';
2
+
3
+ export type CardTemplatesConfig = {
4
+ /**
5
+ * token
6
+ */
7
+ token: Token;
8
+
9
+ /**
10
+ * Url of OneReach service discovery api
11
+ */
12
+ discoveryUrl?: string;
13
+
14
+ /**
15
+ * Account ID for cross-account requests (super admin only)
16
+ */
17
+ accountId?: string;
18
+
19
+ /**
20
+ * Url of OneReach DataHub api
21
+ */
22
+ dataHubUrl?: string;
23
+ };
24
+
25
+ export type CardTemplate = {
26
+ id: string;
27
+ template: {
28
+ category: string;
29
+ description: string;
30
+ help: string | null;
31
+ icon: string;
32
+ iconUrl: string | null;
33
+ implicitly: unknown;
34
+ label: string;
35
+ publishedBy: string;
36
+ tags: string[] | null;
37
+ type: string | null;
38
+ version: string;
39
+ };
40
+ };
41
+
42
+ export type Card = {
43
+ id?: string;
44
+ schemaVersion?: number;
45
+ dateCreated?: number;
46
+ dateModified?: number;
47
+ data: {
48
+ presentation: {
49
+ template: string;
50
+ code: string;
51
+ style: string;
52
+ data: {
53
+ [key: string]: unknown;
54
+ } | null;
55
+ };
56
+ form: {
57
+ template: string;
58
+ code: string;
59
+ style: string;
60
+ data: {
61
+ [key: string]: unknown;
62
+ };
63
+ };
64
+ data: {
65
+ description: string;
66
+ height: string;
67
+ heightOption: string;
68
+ label: string;
69
+ viewClasses: string[];
70
+ width: string;
71
+ widthOption: string;
72
+ };
73
+ tagIds?: string[] | null;
74
+ };
75
+ reference?: string | null;
76
+ template?: string | null;
77
+ };
78
+
79
+ export type ListCardTemplatesParams = {
80
+ projection?: string[];
81
+ limit?: number;
82
+ queryParams?: {
83
+ sourceId: string;
84
+ };
85
+ };
86
+
87
+ export type GetCardTemplateByIdParams = {
88
+ projection?: string[];
89
+ };
@@ -0,0 +1,14 @@
1
+ import { getQueryProjectionPart } from '@or-sdk/data-hub';
2
+ import { DEFAULT_PROJECTION_GET_LIST } from '../constants';
3
+
4
+ function getGetByIdQuery({ projection = [] }: { projection: string[]; }): string {
5
+ return `query getTemplate($entity: TemplateType!, $params: GetInput!, $sourceId: String) {
6
+ getTemplate(entity: $entity, params: $params, sourceId: $sourceId) {
7
+ ... on Card {${getQueryProjectionPart(projection.length ? projection : DEFAULT_PROJECTION_GET_LIST)}
8
+ }
9
+ }
10
+ }
11
+ `;
12
+ }
13
+
14
+ export default getGetByIdQuery;
@@ -0,0 +1,16 @@
1
+ import { getQueryProjectionPart } from '@or-sdk/data-hub';
2
+ import { DEFAULT_PROJECTION_LIST } from '../constants';
3
+
4
+ function getListQuery({ projection = [] }: { projection: string[]; }): string {
5
+ return `query listTemplates($entity: TemplateType!, $params: ListInput!, $sourceId: String, $forceSandbox: Boolean) {
6
+ listTemplates(entity: $entity, params: $params, sourceId: $sourceId, forceSandbox: $forceSandbox) {
7
+ records {
8
+ ... on Card {${getQueryProjectionPart(projection.length ? projection : DEFAULT_PROJECTION_LIST)}
9
+ }
10
+ }
11
+ last
12
+ }
13
+ }`;
14
+ }
15
+
16
+ export default getListQuery;
@@ -0,0 +1,64 @@
1
+ import { v4 as uuidv4 } from 'uuid';
2
+
3
+ function getNewCardTemplate(stepId?: string) {
4
+ return {
5
+ id: stepId || uuidv4(), // this won't change in a future versions of a step
6
+ version: '0.0.1',
7
+ cacheVersion: uuidv4(), // this will change every time you save a step template
8
+ label: '',
9
+ icon: '',
10
+ iconType: 'default',
11
+ iconUrl: '',
12
+ shape: 'circle',
13
+ description: '',
14
+ dateCreated: Date.now(),
15
+ dateModified: Date.now(),
16
+ publishedBy: '',
17
+ template: `/* Your custom logic goes here. */
18
+ // This exits the step down the exit leg labeled \`next\`
19
+ return this.exitStep('next' /*, outputData */ );
20
+ // This second argument is optional output data, which
21
+ // will be stored in the step's merge field upon exit.`,
22
+ categories: [],
23
+ form: {
24
+ style: '',
25
+ template: '',
26
+ code: '',
27
+ },
28
+ data: {
29
+ exits: [],
30
+ },
31
+ modules: [],
32
+ reporting: {
33
+ step: {
34
+ label: 'Step',
35
+ type: 'step',
36
+ enabled: true,
37
+ tags: [],
38
+ },
39
+ },
40
+ outputExample: null,
41
+ formBuilder: {
42
+ stepExits: [
43
+ {
44
+ component: 'exitStatic',
45
+ data: {
46
+ id: 'next',
47
+ label: 'next',
48
+ },
49
+ },
50
+ ],
51
+ stepInputs: [],
52
+ hasDataOut: false,
53
+ hasProcessError: false,
54
+ outputExample: null,
55
+ formTemplate: `<!-- Tread lightly here there be form elements from Design tab, you've been warned! -->
56
+ <%= inputs ? inputs.join('\\n ') : '' %>
57
+ <!-- Form elements from Design tab will end here -->`,
58
+ },
59
+ rawMode: false,
60
+ hooks: null,
61
+ };
62
+ }
63
+
64
+ export default getNewCardTemplate;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @internal
3
+ */
4
+
5
+ export { default as getListQuery } from './getListQuery';
6
+ export { default as getGetByIdQuery } from './getGetByIdQuery';
7
+ export { default as getNewCardTemplate } from './getNewCardTemplate';
@@ -0,0 +1,8 @@
1
+ {
2
+ "extends": "./tsconfig.esm.json",
3
+ "compilerOptions": {
4
+ "declarationDir": "./dist/types",
5
+ "rootDir": "./src",
6
+ "declaration": true
7
+ }
8
+ }
@@ -0,0 +1,12 @@
1
+ {
2
+ "extends": "../../tsconfig.json",
3
+ "compilerOptions": {
4
+ "outDir": "./dist/esm",
5
+ "declarationDir": "./dist/types",
6
+ "module": "ES6",
7
+ "target": "es6",
8
+ "rootDir": "./src",
9
+ "declaration": true,
10
+ "declarationMap": true
11
+ }
12
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,7 @@
1
+ {
2
+ "extends": "../../tsconfig.json",
3
+ "compilerOptions": {
4
+ "outDir": "./dist/cjs/",
5
+ "rootDir": "./src"
6
+ }
7
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "extends": "../../tsconfig.json",
3
+ "compilerOptions": {
4
+ "outDir": "./dist/types/",
5
+ "rootDir": "./src",
6
+ "declaration": true,
7
+ "declarationMap": true,
8
+ "emitDeclarationOnly": true
9
+ }
10
+ }