@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.
- package/dist/cjs/CardTemplates.js +198 -0
- package/dist/cjs/CardTemplates.js.map +1 -0
- package/dist/cjs/constants.js +57 -0
- package/dist/cjs/constants.js.map +1 -0
- package/dist/cjs/index.js +21 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/types.js +3 -0
- package/dist/cjs/types.js.map +1 -0
- package/dist/cjs/utils/getGetByIdQuery.js +10 -0
- package/dist/cjs/utils/getGetByIdQuery.js.map +1 -0
- package/dist/cjs/utils/getListQuery.js +10 -0
- package/dist/cjs/utils/getListQuery.js.map +1 -0
- package/dist/cjs/utils/getNewCardTemplate.js +59 -0
- package/dist/cjs/utils/getNewCardTemplate.js.map +1 -0
- package/dist/cjs/utils/index.js +13 -0
- package/dist/cjs/utils/index.js.map +1 -0
- package/dist/esm/CardTemplates.js +125 -0
- package/dist/esm/CardTemplates.js.map +1 -0
- package/dist/esm/constants.js +105 -0
- package/dist/esm/constants.js.map +1 -0
- package/dist/esm/index.js +3 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/types.js +2 -0
- package/dist/esm/types.js.map +1 -0
- package/dist/esm/utils/getGetByIdQuery.js +13 -0
- package/dist/esm/utils/getGetByIdQuery.js.map +1 -0
- package/dist/esm/utils/getListQuery.js +15 -0
- package/dist/esm/utils/getListQuery.js.map +1 -0
- package/dist/esm/utils/getNewCardTemplate.js +63 -0
- package/dist/esm/utils/getNewCardTemplate.js.map +1 -0
- package/dist/esm/utils/index.js +4 -0
- package/dist/esm/utils/index.js.map +1 -0
- package/dist/types/CardTemplates.d.ts +63 -0
- package/dist/types/CardTemplates.d.ts.map +1 -0
- package/dist/types/constants.d.ts +6 -0
- package/dist/types/constants.d.ts.map +1 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/types.d.ts +70 -0
- package/dist/types/types.d.ts.map +1 -0
- package/dist/types/utils/getGetByIdQuery.d.ts +5 -0
- package/dist/types/utils/getGetByIdQuery.d.ts.map +1 -0
- package/dist/types/utils/getListQuery.d.ts +5 -0
- package/dist/types/utils/getListQuery.d.ts.map +1 -0
- package/dist/types/utils/getNewCardTemplate.d.ts +52 -0
- package/dist/types/utils/getNewCardTemplate.d.ts.map +1 -0
- package/dist/types/utils/index.d.ts +4 -0
- package/dist/types/utils/index.d.ts.map +1 -0
- package/package.json +32 -0
- package/src/CardTemplates.ts +177 -0
- package/src/constants.ts +109 -0
- package/src/index.ts +2 -0
- package/src/types.ts +89 -0
- package/src/utils/getGetByIdQuery.ts +14 -0
- package/src/utils/getListQuery.ts +16 -0
- package/src/utils/getNewCardTemplate.ts +64 -0
- package/src/utils/index.ts +7 -0
- package/tsconfig.dev.json +8 -0
- package/tsconfig.esm.json +12 -0
- package/tsconfig.json +7 -0
- package/tsconfig.types.json +10 -0
package/src/constants.ts
ADDED
|
@@ -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
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;
|
package/tsconfig.json
ADDED