@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,3 @@
1
+ export { CardTemplates } from './CardTemplates';
2
+ export * from './types';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,cAAc,SAAS,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,13 @@
1
+ import { getQueryProjectionPart } from '@or-sdk/data-hub';
2
+ import { DEFAULT_PROJECTION_GET_LIST } from '../constants';
3
+ function getGetByIdQuery({ projection = [] }) {
4
+ return `query getTemplate($entity: TemplateType!, $params: GetInput!, $sourceId: String) {
5
+ getTemplate(entity: $entity, params: $params, sourceId: $sourceId) {
6
+ ... on Card {${getQueryProjectionPart(projection.length ? projection : DEFAULT_PROJECTION_GET_LIST)}
7
+ }
8
+ }
9
+ }
10
+ `;
11
+ }
12
+ export default getGetByIdQuery;
13
+ //# sourceMappingURL=getGetByIdQuery.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getGetByIdQuery.js","sourceRoot":"","sources":["../../../src/utils/getGetByIdQuery.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAAE,2BAA2B,EAAE,MAAM,cAAc,CAAC;AAE3D,SAAS,eAAe,CAAC,EAAE,UAAU,GAAG,EAAE,EAA6B;IACrE,OAAO;;mBAEU,sBAAsB,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,2BAA2B,CAAC;;;;CAItG,CAAC;AACF,CAAC;AAED,eAAe,eAAe,CAAC"}
@@ -0,0 +1,15 @@
1
+ import { getQueryProjectionPart } from '@or-sdk/data-hub';
2
+ import { DEFAULT_PROJECTION_LIST } from '../constants';
3
+ function getListQuery({ projection = [] }) {
4
+ return `query listTemplates($entity: TemplateType!, $params: ListInput!, $sourceId: String, $forceSandbox: Boolean) {
5
+ listTemplates(entity: $entity, params: $params, sourceId: $sourceId, forceSandbox: $forceSandbox) {
6
+ records {
7
+ ... on Card {${getQueryProjectionPart(projection.length ? projection : DEFAULT_PROJECTION_LIST)}
8
+ }
9
+ }
10
+ last
11
+ }
12
+ }`;
13
+ }
14
+ export default getListQuery;
15
+ //# sourceMappingURL=getListQuery.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getListQuery.js","sourceRoot":"","sources":["../../../src/utils/getListQuery.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAEvD,SAAS,YAAY,CAAC,EAAE,UAAU,GAAG,EAAE,EAA6B;IAClE,OAAO;;;qBAGY,sBAAsB,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,uBAAuB,CAAC;;;;;EAKnG,CAAC;AACH,CAAC;AAED,eAAe,YAAY,CAAC"}
@@ -0,0 +1,63 @@
1
+ import { v4 as uuidv4 } from 'uuid';
2
+ function getNewCardTemplate(stepId) {
3
+ return {
4
+ id: stepId || uuidv4(),
5
+ version: '0.0.1',
6
+ cacheVersion: uuidv4(),
7
+ label: '',
8
+ icon: '',
9
+ iconType: 'default',
10
+ iconUrl: '',
11
+ shape: 'circle',
12
+ description: '',
13
+ dateCreated: Date.now(),
14
+ dateModified: Date.now(),
15
+ publishedBy: '',
16
+ template: `/* Your custom logic goes here. */
17
+ // This exits the step down the exit leg labeled \`next\`
18
+ return this.exitStep('next' /*, outputData */ );
19
+ // This second argument is optional output data, which
20
+ // will be stored in the step's merge field upon exit.`,
21
+ categories: [],
22
+ form: {
23
+ style: '',
24
+ template: '',
25
+ code: '',
26
+ },
27
+ data: {
28
+ exits: [],
29
+ },
30
+ modules: [],
31
+ reporting: {
32
+ step: {
33
+ label: 'Step',
34
+ type: 'step',
35
+ enabled: true,
36
+ tags: [],
37
+ },
38
+ },
39
+ outputExample: null,
40
+ formBuilder: {
41
+ stepExits: [
42
+ {
43
+ component: 'exitStatic',
44
+ data: {
45
+ id: 'next',
46
+ label: 'next',
47
+ },
48
+ },
49
+ ],
50
+ stepInputs: [],
51
+ hasDataOut: false,
52
+ hasProcessError: false,
53
+ outputExample: null,
54
+ formTemplate: `<!-- Tread lightly here there be form elements from Design tab, you've been warned! -->
55
+ <%= inputs ? inputs.join('\\n ') : '' %>
56
+ <!-- Form elements from Design tab will end here -->`,
57
+ },
58
+ rawMode: false,
59
+ hooks: null,
60
+ };
61
+ }
62
+ export default getNewCardTemplate;
63
+ //# sourceMappingURL=getNewCardTemplate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getNewCardTemplate.js","sourceRoot":"","sources":["../../../src/utils/getNewCardTemplate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAC;AAEpC,SAAS,kBAAkB,CAAC,MAAe;IACzC,OAAO;QACL,EAAE,EAAE,MAAM,IAAI,MAAM,EAAE;QACtB,OAAO,EAAE,OAAO;QAChB,YAAY,EAAE,MAAM,EAAE;QACtB,KAAK,EAAE,EAAE;QACT,IAAI,EAAE,EAAE;QACR,QAAQ,EAAE,SAAS;QACnB,OAAO,EAAE,EAAE;QACX,KAAK,EAAE,QAAQ;QACf,WAAW,EAAE,EAAE;QACf,WAAW,EAAE,IAAI,CAAC,GAAG,EAAE;QACvB,YAAY,EAAE,IAAI,CAAC,GAAG,EAAE;QACxB,WAAW,EAAE,EAAE;QACf,QAAQ,EAAE;;;;wDAI0C;QACpD,UAAU,EAAE,EAAE;QACd,IAAI,EAAE;YACJ,KAAK,EAAE,EAAE;YACT,QAAQ,EAAE,EAAE;YACZ,IAAI,EAAE,EAAE;SACT;QACD,IAAI,EAAE;YACJ,KAAK,EAAE,EAAE;SACV;QACD,OAAO,EAAE,EAAE;QACX,SAAS,EAAE;YACT,IAAI,EAAE;gBACJ,KAAK,EAAE,MAAM;gBACb,IAAI,EAAE,MAAM;gBACZ,OAAO,EAAE,IAAI;gBACb,IAAI,EAAE,EAAE;aACT;SACF;QACD,aAAa,EAAE,IAAI;QACnB,WAAW,EAAE;YACX,SAAS,EAAE;gBACT;oBACE,SAAS,EAAE,YAAY;oBACvB,IAAI,EAAE;wBACJ,EAAE,EAAE,MAAM;wBACV,KAAK,EAAE,MAAM;qBACd;iBACF;aACF;YACD,UAAU,EAAE,EAAE;YACd,UAAU,EAAE,KAAK;YACjB,eAAe,EAAE,KAAK;YACtB,aAAa,EAAE,IAAI;YACnB,YAAY,EAAE;;qDAEiC;SAChD;QACD,OAAO,EAAE,KAAK;QACd,KAAK,EAAE,IAAI;KACZ,CAAC;AACJ,CAAC;AAED,eAAe,kBAAkB,CAAC"}
@@ -0,0 +1,4 @@
1
+ export { default as getListQuery } from './getListQuery';
2
+ export { default as getGetByIdQuery } from './getGetByIdQuery';
3
+ export { default as getNewCardTemplate } from './getNewCardTemplate';
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,sBAAsB,CAAC"}
@@ -0,0 +1,63 @@
1
+ import { List } from '@or-sdk/base';
2
+ import { Card, CardTemplate, CardTemplatesConfig, GetCardTemplateByIdParams, ListCardTemplatesParams } from './types';
3
+ export declare class CardTemplates {
4
+ private readonly dataHub;
5
+ constructor(params: CardTemplatesConfig);
6
+ listCardTemplates(params?: ListCardTemplatesParams): Promise<List<CardTemplate>>;
7
+ getCardTemplateById(cardTemplateId: string, params?: GetCardTemplateByIdParams): Promise<CardTemplate>;
8
+ download(cardTemplateId: string, viewId?: string): Promise<Card>;
9
+ upgrade(cardTemplateId: string, options?: {}): Promise<{
10
+ id: string;
11
+ }>;
12
+ static getNewCardTemplate(stepId?: string): {
13
+ id: string;
14
+ version: string;
15
+ cacheVersion: string;
16
+ label: string;
17
+ icon: string;
18
+ iconType: string;
19
+ iconUrl: string;
20
+ shape: string;
21
+ description: string;
22
+ dateCreated: number;
23
+ dateModified: number;
24
+ publishedBy: string;
25
+ template: string;
26
+ categories: never[];
27
+ form: {
28
+ style: string;
29
+ template: string;
30
+ code: string;
31
+ };
32
+ data: {
33
+ exits: never[];
34
+ };
35
+ modules: never[];
36
+ reporting: {
37
+ step: {
38
+ label: string;
39
+ type: string;
40
+ enabled: boolean;
41
+ tags: never[];
42
+ };
43
+ };
44
+ outputExample: null;
45
+ formBuilder: {
46
+ stepExits: {
47
+ component: string;
48
+ data: {
49
+ id: string;
50
+ label: string;
51
+ };
52
+ }[];
53
+ stepInputs: never[];
54
+ hasDataOut: boolean;
55
+ hasProcessError: boolean;
56
+ outputExample: null;
57
+ formTemplate: string;
58
+ };
59
+ rawMode: boolean;
60
+ hooks: null;
61
+ };
62
+ }
63
+ //# sourceMappingURL=CardTemplates.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CardTemplates.d.ts","sourceRoot":"","sources":["../../src/CardTemplates.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAEpC,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,mBAAmB,EAAE,yBAAyB,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAWtH,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAU;gBAQtB,MAAM,EAAE,mBAAmB;IAgB1B,iBAAiB,CAAC,MAAM,GAAE,uBAA4B,GAAG,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IAmC3F,mBAAmB,CAAC,cAAc,EAAE,MAAM,EAAE,MAAM,GAAE,yBAA8B,GAAG,OAAO,CAAC,YAAY,CAAC;IAqCnG,QAAQ,CAAC,cAAc,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAgChE,OAAO,CAAC,cAAc,EAAE,MAAM,EAAE,OAAO,KAAK,GAAG,OAAO,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;KAAE,CAAC;WA8BtE,kBAAkB,CAAC,MAAM,CAAC,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAIjD"}
@@ -0,0 +1,6 @@
1
+ export declare const DEFAULT_PROJECTION_LIST: string[];
2
+ export declare const DEFAULT_PROJECTION_GET_LIST: string[];
3
+ export declare const QUERY_DOWNLOAD_TO = "mutation downloadTo($entity: TemplateType!, $data: DownloadInput!) {\n downloadTo(entity: $entity, data: $data) {\n ... on Card {\n id\n schemaVersion\n dateCreated\n dateModified\n data {\n data\n form {\n code\n data\n style\n template\n }\n presentation {\n code\n data\n style\n template\n }\n tagIds\n }\n reference {\n id\n type\n }\n template {\n category\n description\n help\n icon\n iconUrl\n implicitly\n label\n publishedBy\n tags\n type\n version\n }\n deletedDate @include(if: false)\n }\n }\n}\n";
4
+ export declare const QUERY_UPGRADE = "mutation upgrade($entity: TemplateType!, $id: String!, $options: UpgradeOptions) {\n upgrade(entity: $entity, id: $id, options: $options) {\n ... on Card {\n id\n }\n }\n}\n";
5
+ export declare const ENTITY_NAME = "CARD";
6
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,uBAAuB,UAcnC,CAAC;AAEF,eAAO,MAAM,2BAA2B,UAkCvC,CAAC;AAEF,eAAO,MAAM,iBAAiB,+wBA4C7B,CAAC;AAGF,eAAO,MAAM,aAAa,uMAOzB,CAAC;AAEF,eAAO,MAAM,WAAW,SAAS,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { CardTemplates } from './CardTemplates';
2
+ export * from './types';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,cAAc,SAAS,CAAC"}
@@ -0,0 +1,70 @@
1
+ import { Token } from '@or-sdk/base';
2
+ export declare type CardTemplatesConfig = {
3
+ token: Token;
4
+ discoveryUrl?: string;
5
+ accountId?: string;
6
+ dataHubUrl?: string;
7
+ };
8
+ export declare type CardTemplate = {
9
+ id: string;
10
+ template: {
11
+ category: string;
12
+ description: string;
13
+ help: string | null;
14
+ icon: string;
15
+ iconUrl: string | null;
16
+ implicitly: unknown;
17
+ label: string;
18
+ publishedBy: string;
19
+ tags: string[] | null;
20
+ type: string | null;
21
+ version: string;
22
+ };
23
+ };
24
+ export declare type Card = {
25
+ id?: string;
26
+ schemaVersion?: number;
27
+ dateCreated?: number;
28
+ dateModified?: number;
29
+ data: {
30
+ presentation: {
31
+ template: string;
32
+ code: string;
33
+ style: string;
34
+ data: {
35
+ [key: string]: unknown;
36
+ } | null;
37
+ };
38
+ form: {
39
+ template: string;
40
+ code: string;
41
+ style: string;
42
+ data: {
43
+ [key: string]: unknown;
44
+ };
45
+ };
46
+ data: {
47
+ description: string;
48
+ height: string;
49
+ heightOption: string;
50
+ label: string;
51
+ viewClasses: string[];
52
+ width: string;
53
+ widthOption: string;
54
+ };
55
+ tagIds?: string[] | null;
56
+ };
57
+ reference?: string | null;
58
+ template?: string | null;
59
+ };
60
+ export declare type ListCardTemplatesParams = {
61
+ projection?: string[];
62
+ limit?: number;
63
+ queryParams?: {
64
+ sourceId: string;
65
+ };
66
+ };
67
+ export declare type GetCardTemplateByIdParams = {
68
+ projection?: string[];
69
+ };
70
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAErC,oBAAY,mBAAmB,GAAG;IAIhC,KAAK,EAAE,KAAK,CAAC;IAKb,YAAY,CAAC,EAAE,MAAM,CAAC;IAKtB,SAAS,CAAC,EAAE,MAAM,CAAC;IAKnB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,oBAAY,YAAY,GAAG;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE;QACR,QAAQ,EAAE,MAAM,CAAC;QACjB,WAAW,EAAE,MAAM,CAAC;QACpB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;QACpB,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;QACvB,UAAU,EAAE,OAAO,CAAC;QACpB,KAAK,EAAE,MAAM,CAAC;QACd,WAAW,EAAE,MAAM,CAAC;QACpB,IAAI,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;QACtB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;QACpB,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;CACH,CAAC;AAEF,oBAAY,IAAI,GAAG;IACjB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,IAAI,EAAE;QACJ,YAAY,EAAE;YACZ,QAAQ,EAAE,MAAM,CAAC;YACjB,IAAI,EAAE,MAAM,CAAC;YACb,KAAK,EAAE,MAAM,CAAC;YACd,IAAI,EAAE;gBACJ,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;aACxB,GAAG,IAAI,CAAC;SACV,CAAC;QACF,IAAI,EAAE;YACJ,QAAQ,EAAE,MAAM,CAAC;YACjB,IAAI,EAAE,MAAM,CAAC;YACb,KAAK,EAAE,MAAM,CAAC;YACd,IAAI,EAAE;gBACJ,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;aACxB,CAAC;SACH,CAAC;QACF,IAAI,EAAE;YACJ,WAAW,EAAE,MAAM,CAAC;YACpB,MAAM,EAAE,MAAM,CAAC;YACf,YAAY,EAAE,MAAM,CAAC;YACrB,KAAK,EAAE,MAAM,CAAC;YACd,WAAW,EAAE,MAAM,EAAE,CAAC;YACtB,KAAK,EAAE,MAAM,CAAC;YACd,WAAW,EAAE,MAAM,CAAC;SACrB,CAAC;QACF,MAAM,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;KAC1B,CAAC;IACF,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B,CAAC;AAEF,oBAAY,uBAAuB,GAAG;IACpC,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE;QACZ,QAAQ,EAAE,MAAM,CAAC;KAClB,CAAC;CACH,CAAC;AAEF,oBAAY,yBAAyB,GAAG;IACtC,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;CACvB,CAAC"}
@@ -0,0 +1,5 @@
1
+ declare function getGetByIdQuery({ projection }: {
2
+ projection: string[];
3
+ }): string;
4
+ export default getGetByIdQuery;
5
+ //# sourceMappingURL=getGetByIdQuery.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getGetByIdQuery.d.ts","sourceRoot":"","sources":["../../../src/utils/getGetByIdQuery.ts"],"names":[],"mappings":"AAGA,iBAAS,eAAe,CAAC,EAAE,UAAe,EAAE,EAAE;IAAE,UAAU,EAAE,MAAM,EAAE,CAAC;CAAE,GAAG,MAAM,CAQ/E;AAED,eAAe,eAAe,CAAC"}
@@ -0,0 +1,5 @@
1
+ declare function getListQuery({ projection }: {
2
+ projection: string[];
3
+ }): string;
4
+ export default getListQuery;
5
+ //# sourceMappingURL=getListQuery.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getListQuery.d.ts","sourceRoot":"","sources":["../../../src/utils/getListQuery.ts"],"names":[],"mappings":"AAGA,iBAAS,YAAY,CAAC,EAAE,UAAe,EAAE,EAAE;IAAE,UAAU,EAAE,MAAM,EAAE,CAAC;CAAE,GAAG,MAAM,CAU5E;AAED,eAAe,YAAY,CAAC"}
@@ -0,0 +1,52 @@
1
+ declare function getNewCardTemplate(stepId?: string): {
2
+ id: string;
3
+ version: string;
4
+ cacheVersion: string;
5
+ label: string;
6
+ icon: string;
7
+ iconType: string;
8
+ iconUrl: string;
9
+ shape: string;
10
+ description: string;
11
+ dateCreated: number;
12
+ dateModified: number;
13
+ publishedBy: string;
14
+ template: string;
15
+ categories: never[];
16
+ form: {
17
+ style: string;
18
+ template: string;
19
+ code: string;
20
+ };
21
+ data: {
22
+ exits: never[];
23
+ };
24
+ modules: never[];
25
+ reporting: {
26
+ step: {
27
+ label: string;
28
+ type: string;
29
+ enabled: boolean;
30
+ tags: never[];
31
+ };
32
+ };
33
+ outputExample: null;
34
+ formBuilder: {
35
+ stepExits: {
36
+ component: string;
37
+ data: {
38
+ id: string;
39
+ label: string;
40
+ };
41
+ }[];
42
+ stepInputs: never[];
43
+ hasDataOut: boolean;
44
+ hasProcessError: boolean;
45
+ outputExample: null;
46
+ formTemplate: string;
47
+ };
48
+ rawMode: boolean;
49
+ hooks: null;
50
+ };
51
+ export default getNewCardTemplate;
52
+ //# sourceMappingURL=getNewCardTemplate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getNewCardTemplate.d.ts","sourceRoot":"","sources":["../../../src/utils/getNewCardTemplate.ts"],"names":[],"mappings":"AAEA,iBAAS,kBAAkB,CAAC,MAAM,CAAC,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA2D1C;AAED,eAAe,kBAAkB,CAAC"}
@@ -0,0 +1,4 @@
1
+ export { default as getListQuery } from './getListQuery';
2
+ export { default as getGetByIdQuery } from './getGetByIdQuery';
3
+ export { default as getNewCardTemplate } from './getNewCardTemplate';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,sBAAsB,CAAC"}
package/package.json ADDED
@@ -0,0 +1,32 @@
1
+ {
2
+ "version": "1.0.1-beta.493.0",
3
+ "name": "@or-sdk/card-templates",
4
+ "main": "dist/cjs/index.js",
5
+ "module": "dist/esm/index.js",
6
+ "types": "dist/types/index.d.ts",
7
+ "scripts": {
8
+ "build": "npm run clean && npm run build:esm && npm run build:cjs",
9
+ "build:cjs": "tsc --project tsconfig.json",
10
+ "build:esm": "tsc --project tsconfig.esm.json",
11
+ "build:types": "tsc --project tsconfig.types.json",
12
+ "build:watch": "concurrently -r --hide 1,2 \"npm run build:watch:cjs\" \"npm run build:watch:esm\" \"npm run build:watch:types\"",
13
+ "build:watch:cjs": "tsc --project tsconfig.json -w",
14
+ "build:watch:esm": "tsc --project tsconfig.esm.json -w",
15
+ "build:watch:types": "tsc --project tsconfig.types.json -w",
16
+ "clean": "rm -rf ./dist",
17
+ "dev": "npm run build:watch:esm"
18
+ },
19
+ "devDependencies": {
20
+ "@types/uuid": "^8.3.1",
21
+ "concurrently": "^6.4.0",
22
+ "typescript": "^4.4.4"
23
+ },
24
+ "publishConfig": {
25
+ "access": "public"
26
+ },
27
+ "dependencies": {
28
+ "@or-sdk/base": "^0.26.0",
29
+ "@or-sdk/data-hub": "^0.24.0",
30
+ "uuid": "^8.3.2"
31
+ }
32
+ }
@@ -0,0 +1,177 @@
1
+ import { List } from '@or-sdk/base';
2
+ import { DataHub, GraphqlResponse, OperationNames } from '@or-sdk/data-hub';
3
+ import { Card, CardTemplate, CardTemplatesConfig, GetCardTemplateByIdParams, ListCardTemplatesParams } from './types';
4
+ import { ENTITY_NAME, QUERY_DOWNLOAD_TO, QUERY_UPGRADE } from './constants';
5
+ import { getGetByIdQuery, getListQuery, getNewCardTemplate } from './utils';
6
+
7
+ /**
8
+ * OneReach CardTemplates service client
9
+ * ## Installation:
10
+ * ```
11
+ * $ npm i @or-sdk/card-templates
12
+ * ```
13
+ */
14
+ export class CardTemplates {
15
+ private readonly dataHub: DataHub;
16
+
17
+ /**
18
+ * ```typescript
19
+ * import { CardTemplates } from '@or-sdk/card-templates'
20
+ * const cardTemplates = new CardTemplates({token: 'my-account-token-string', discoveryUrl: 'http://example.cardTemplates/endpoint'});
21
+ * ```
22
+ */
23
+ constructor(params: CardTemplatesConfig) {
24
+ const { token, discoveryUrl, dataHubUrl } = params;
25
+
26
+ this.dataHub = new DataHub({
27
+ token,
28
+ discoveryUrl,
29
+ dataHubUrl,
30
+ });
31
+ }
32
+
33
+ /**
34
+ * List card templates
35
+ * ```typescript
36
+ * const result = await cardTemplates.listCardsTemplates();
37
+ * ```
38
+ */
39
+ public async listCardTemplates(params: ListCardTemplatesParams = {}): Promise<List<CardTemplate>> {
40
+ const { projection = [], ...varPrams } = params;
41
+
42
+ const variables = {
43
+ entity: ENTITY_NAME,
44
+ params: {
45
+ queryParams: {},
46
+ limit: 30,
47
+
48
+ // overrides
49
+ ...varPrams,
50
+ },
51
+ forceSandbox: false,
52
+ sourceId: varPrams?.queryParams?.sourceId,
53
+ };
54
+
55
+ const operationName = this.dataHub.getOperationName(OperationNames.LIST_TEMPLATES);
56
+
57
+ const data = {
58
+ operationName,
59
+ query: getListQuery({
60
+ projection,
61
+ }),
62
+ variables,
63
+ };
64
+
65
+ return this.dataHub.getFullList<CardTemplate>('POST', '/graphql', data);
66
+ }
67
+
68
+ /**
69
+ * Get card template by id
70
+ * ```typescript
71
+ * const result = await cardTemplates.getCardTemplateById('card-template-id');
72
+ * ```
73
+ */
74
+ async getCardTemplateById(cardTemplateId: string, params: GetCardTemplateByIdParams = {}): Promise<CardTemplate> {
75
+ const { projection = [], ...varPrams } = params;
76
+ const variables = {
77
+ entity: ENTITY_NAME,
78
+ params: {
79
+ id: cardTemplateId,
80
+
81
+ // overrides
82
+ ...varPrams,
83
+ },
84
+ };
85
+
86
+ const operationName = 'getTemplate';
87
+
88
+ const data = {
89
+ operationName,
90
+ query: getGetByIdQuery({
91
+ projection,
92
+ }),
93
+ variables,
94
+ };
95
+
96
+ const result = await this.dataHub.makeRequest<GraphqlResponse<CardTemplate>>({
97
+ method: 'POST',
98
+ route: '/graphql',
99
+ data,
100
+ });
101
+
102
+ return result.data[operationName] as CardTemplate;
103
+ }
104
+
105
+ /**
106
+ * Download card template
107
+ * ```typescript
108
+ * const result = await cardTemplates.download('card-template-id');
109
+ * ```
110
+ */
111
+ public async download(cardTemplateId: string, viewId?: string): Promise<Card> {
112
+ const variables = {
113
+ entity: ENTITY_NAME,
114
+ data: {
115
+ id: cardTemplateId,
116
+ body: { viewId },
117
+ },
118
+ };
119
+
120
+ const operationName = 'downloadTo';
121
+
122
+ const data = {
123
+ operationName,
124
+ query: QUERY_DOWNLOAD_TO,
125
+ variables,
126
+ };
127
+
128
+ const result = await this.dataHub.makeRequest<GraphqlResponse<Card>>({
129
+ method: 'POST',
130
+ route: '/graphql',
131
+ data,
132
+ });
133
+
134
+ return result.data[operationName] as Card;
135
+ }
136
+
137
+ /**
138
+ * Upgrade card template
139
+ * ```typescript
140
+ * const result = await cardTemplates.upgrade('card-template-id');
141
+ * ```
142
+ */
143
+ public async upgrade(cardTemplateId: string, options = {}): Promise<{ id: string; }> {
144
+ const variables = {
145
+ entity: ENTITY_NAME,
146
+ id: cardTemplateId,
147
+ options,
148
+ };
149
+
150
+ const operationName = 'upgrade';
151
+
152
+ const data = {
153
+ operationName,
154
+ query: QUERY_UPGRADE,
155
+ variables,
156
+ };
157
+
158
+ const result = await this.dataHub.makeRequest<GraphqlResponse<{ id: string; }>>({
159
+ method: 'POST',
160
+ route: '/graphql',
161
+ data,
162
+ });
163
+
164
+ return result.data[operationName]!;
165
+ }
166
+
167
+ /**
168
+ * Generate new card template
169
+ * ```typescript
170
+ * const result = CardTemplates.getNewCardTemplate();
171
+ * ```
172
+ */
173
+ public static getNewCardTemplate(stepId?: string) {
174
+ return getNewCardTemplate(stepId);
175
+ }
176
+
177
+ }