@affinidi/cli 1.23.0 → 1.24.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 (93) hide show
  1. package/dist/commands/create/project.d.ts +4 -1
  2. package/dist/commands/create/project.js +6 -3
  3. package/dist/commands/create/project.js.map +1 -1
  4. package/dist/commands/create/schema.d.ts +19 -0
  5. package/dist/commands/create/schema.js +111 -0
  6. package/dist/commands/create/schema.js.map +1 -0
  7. package/dist/commands/generate-application/index.d.ts +4 -1
  8. package/dist/commands/generate-application/index.js +4 -1
  9. package/dist/commands/generate-application/index.js.map +1 -1
  10. package/dist/commands/issue-vc.d.ts +5 -1
  11. package/dist/commands/issue-vc.js +9 -11
  12. package/dist/commands/issue-vc.js.map +1 -1
  13. package/dist/commands/list/index.d.ts +2 -0
  14. package/dist/commands/list/index.js +6 -5
  15. package/dist/commands/list/index.js.map +1 -1
  16. package/dist/commands/list/projects.d.ts +4 -1
  17. package/dist/commands/list/projects.js +6 -3
  18. package/dist/commands/list/projects.js.map +1 -1
  19. package/dist/commands/list/schemas.d.ts +4 -2
  20. package/dist/commands/list/schemas.js +7 -6
  21. package/dist/commands/list/schemas.js.map +1 -1
  22. package/dist/commands/login/index.d.ts +4 -1
  23. package/dist/commands/login/index.js +4 -2
  24. package/dist/commands/login/index.js.map +1 -1
  25. package/dist/commands/logout/index.d.ts +3 -1
  26. package/dist/commands/logout/index.js +2 -2
  27. package/dist/commands/logout/index.js.map +1 -1
  28. package/dist/commands/show/index.d.ts +2 -0
  29. package/dist/commands/show/index.js +7 -6
  30. package/dist/commands/show/index.js.map +1 -1
  31. package/dist/commands/show/project.d.ts +4 -1
  32. package/dist/commands/show/project.js +10 -6
  33. package/dist/commands/show/project.js.map +1 -1
  34. package/dist/commands/show/schema.d.ts +4 -2
  35. package/dist/commands/show/schema.js +9 -5
  36. package/dist/commands/show/schema.js.map +1 -1
  37. package/dist/commands/sign-up/index.d.ts +3 -1
  38. package/dist/commands/sign-up/index.js +3 -2
  39. package/dist/commands/sign-up/index.js.map +1 -1
  40. package/dist/commands/use/index.d.ts +2 -0
  41. package/dist/commands/use/index.js +5 -4
  42. package/dist/commands/use/index.js.map +1 -1
  43. package/dist/commands/use/project.d.ts +4 -1
  44. package/dist/commands/use/project.js +8 -4
  45. package/dist/commands/use/project.js.map +1 -1
  46. package/dist/commands/verify-vc.d.ts +4 -1
  47. package/dist/commands/verify-vc.js +6 -8
  48. package/dist/commands/verify-vc.js.map +1 -1
  49. package/dist/errors/index.d.ts +26 -19
  50. package/dist/errors/index.js +47 -30
  51. package/dist/errors/index.js.map +1 -1
  52. package/dist/fixtures/mock-schemas.d.ts +1 -0
  53. package/dist/fixtures/mock-schemas.js +14 -1
  54. package/dist/fixtures/mock-schemas.js.map +1 -1
  55. package/dist/render/texts.d.ts +2 -0
  56. package/dist/render/texts.js +18 -4
  57. package/dist/render/texts.js.map +1 -1
  58. package/dist/services/iam/index.js +3 -3
  59. package/dist/services/iam/index.js.map +1 -1
  60. package/dist/services/issuance/index.js +3 -3
  61. package/dist/services/issuance/index.js.map +1 -1
  62. package/dist/services/schema-manager/generator/context-generator.d.ts +2 -0
  63. package/dist/services/schema-manager/generator/context-generator.js +42 -0
  64. package/dist/services/schema-manager/generator/context-generator.js.map +1 -0
  65. package/dist/services/schema-manager/generator/helpers.d.ts +22 -0
  66. package/dist/services/schema-manager/generator/helpers.js +29 -0
  67. package/dist/services/schema-manager/generator/helpers.js.map +1 -0
  68. package/dist/services/schema-manager/generator/mapping.d.ts +6 -0
  69. package/dist/services/schema-manager/generator/mapping.js +22 -0
  70. package/dist/services/schema-manager/generator/mapping.js.map +1 -0
  71. package/dist/services/schema-manager/generator/schema-generator.d.ts +2 -0
  72. package/dist/services/schema-manager/generator/schema-generator.js +103 -0
  73. package/dist/services/schema-manager/generator/schema-generator.js.map +1 -0
  74. package/dist/services/schema-manager/generator/types.d.ts +87 -0
  75. package/dist/services/schema-manager/generator/types.js +15 -0
  76. package/dist/services/schema-manager/generator/types.js.map +1 -0
  77. package/dist/services/schema-manager/index.d.ts +11 -1
  78. package/dist/services/schema-manager/index.js +24 -2
  79. package/dist/services/schema-manager/index.js.map +1 -1
  80. package/dist/services/schema-manager/schemaParser/schema-parser.d.ts +5 -0
  81. package/dist/services/schema-manager/schemaParser/schema-parser.js +35 -0
  82. package/dist/services/schema-manager/schemaParser/schema-parser.js.map +1 -0
  83. package/dist/services/user-management/index.js +13 -7
  84. package/dist/services/user-management/index.js.map +1 -1
  85. package/dist/services/verification/index.js +1 -1
  86. package/dist/services/verification/index.js.map +1 -1
  87. package/dist/user-actions/index.d.ts +1 -1
  88. package/dist/user-actions/index.js +2 -1
  89. package/dist/user-actions/index.js.map +1 -1
  90. package/dist/user-actions/prompts.d.ts +1 -0
  91. package/dist/user-actions/prompts.js +5 -1
  92. package/dist/user-actions/prompts.js.map +1 -1
  93. package/package.json +1 -1
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.mockSchemaDto = exports.mockSchemaDtoTwo = exports.mockSchemaDtoOne = void 0;
3
+ exports.mockSchemaDto = exports.mockSchemaDtoUnlisted = exports.mockSchemaDtoTwo = exports.mockSchemaDtoOne = void 0;
4
4
  exports.mockSchemaDtoOne = {
5
5
  id: 'CealBusinessCardV1-0',
6
6
  parentId: null,
@@ -27,6 +27,19 @@ exports.mockSchemaDtoTwo = {
27
27
  jsonSchemaUrl: 'https://schema.affinidi.com/LeadershipWorkshopBadgeV1-0.json',
28
28
  jsonLdContextUrl: 'https://schema.affinidi.com/LeadershipWorkshopBadgeV1-0.jsonld',
29
29
  };
30
+ exports.mockSchemaDtoUnlisted = {
31
+ id: '@did:elem:EiC8lGLPTODEnlyZYMQHGIWrXJ6niReJdyWAt5NxoXOOCw/nestdNamesV1-0',
32
+ parentId: null,
33
+ authorDid: 'did:elem:AwesomeDID',
34
+ description: 'Nested Names',
35
+ createdAt: '2022-11-16T14:17:25.268Z',
36
+ namespace: 'Some-namespae',
37
+ type: 'nestdNames',
38
+ version: 1,
39
+ revision: 0,
40
+ jsonSchemaUrl: 'https://schema.affinidi.com/did:elem:AwesomeDID/nestdNamesV1-0.json',
41
+ jsonLdContextUrl: 'https://schema.affinidi.com/did:elem:AwesomeDID/nestdNamesV1-0.jsonld',
42
+ };
30
43
  exports.mockSchemaDto = {
31
44
  schemas: [exports.mockSchemaDtoOne, exports.mockSchemaDtoTwo],
32
45
  count: 2,
@@ -1 +1 @@
1
- {"version":3,"file":"mock-schemas.js","sourceRoot":"","sources":["../../src/fixtures/mock-schemas.ts"],"names":[],"mappings":";;;AAEa,QAAA,gBAAgB,GAAc;IACzC,EAAE,EAAE,sBAAsB;IAC1B,QAAQ,EAAE,IAAI;IACd,SAAS,EAAE,yDAAyD;IACpE,WAAW,EAAE,+BAA+B;IAC5C,SAAS,EAAE,0BAA0B;IACrC,SAAS,EAAE,IAAI;IACf,IAAI,EAAE,kBAAkB;IACxB,OAAO,EAAE,CAAC;IACV,QAAQ,EAAE,CAAC;IACX,aAAa,EAAE,uDAAuD;IACtE,gBAAgB,EAAE,yDAAyD;CAC5E,CAAA;AAEY,QAAA,gBAAgB,GAAc;IACzC,EAAE,EAAE,6BAA6B;IACjC,QAAQ,EAAE,eAAe;IACzB,SAAS,EAAE,yDAAyD;IACpE,WAAW,EAAE,2BAA2B;IACxC,SAAS,EAAE,0BAA0B;IACrC,SAAS,EAAE,IAAI;IACf,IAAI,EAAE,yBAAyB;IAC/B,OAAO,EAAE,CAAC;IACV,QAAQ,EAAE,CAAC;IACX,aAAa,EAAE,8DAA8D;IAC7E,gBAAgB,EAAE,gEAAgE;CACnF,CAAA;AAEY,QAAA,aAAa,GAA2B;IACnD,OAAO,EAAE,CAAC,wBAAgB,EAAE,wBAAgB,CAAC;IAC7C,KAAK,EAAE,CAAC;CACT,CAAA"}
1
+ {"version":3,"file":"mock-schemas.js","sourceRoot":"","sources":["../../src/fixtures/mock-schemas.ts"],"names":[],"mappings":";;;AAEa,QAAA,gBAAgB,GAAc;IACzC,EAAE,EAAE,sBAAsB;IAC1B,QAAQ,EAAE,IAAI;IACd,SAAS,EAAE,yDAAyD;IACpE,WAAW,EAAE,+BAA+B;IAC5C,SAAS,EAAE,0BAA0B;IACrC,SAAS,EAAE,IAAI;IACf,IAAI,EAAE,kBAAkB;IACxB,OAAO,EAAE,CAAC;IACV,QAAQ,EAAE,CAAC;IACX,aAAa,EAAE,uDAAuD;IACtE,gBAAgB,EAAE,yDAAyD;CAC5E,CAAA;AAEY,QAAA,gBAAgB,GAAc;IACzC,EAAE,EAAE,6BAA6B;IACjC,QAAQ,EAAE,eAAe;IACzB,SAAS,EAAE,yDAAyD;IACpE,WAAW,EAAE,2BAA2B;IACxC,SAAS,EAAE,0BAA0B;IACrC,SAAS,EAAE,IAAI;IACf,IAAI,EAAE,yBAAyB;IAC/B,OAAO,EAAE,CAAC;IACV,QAAQ,EAAE,CAAC;IACX,aAAa,EAAE,8DAA8D;IAC7E,gBAAgB,EAAE,gEAAgE;CACnF,CAAA;AAEY,QAAA,qBAAqB,GAAc;IAC9C,EAAE,EAAE,yEAAyE;IAC7E,QAAQ,EAAE,IAAI;IACd,SAAS,EAAE,qBAAqB;IAChC,WAAW,EAAE,cAAc;IAC3B,SAAS,EAAE,0BAA0B;IACrC,SAAS,EAAE,eAAe;IAC1B,IAAI,EAAE,YAAY;IAClB,OAAO,EAAE,CAAC;IACV,QAAQ,EAAE,CAAC;IACX,aAAa,EAAE,qEAAqE;IACpF,gBAAgB,EAAE,uEAAuE;CAC1F,CAAA;AAEY,QAAA,aAAa,GAA2B;IACnD,OAAO,EAAE,CAAC,wBAAgB,EAAE,wBAAgB,CAAC;IAC7C,KAAK,EAAE,CAAC;CACT,CAAA"}
@@ -1,3 +1,4 @@
1
+ export declare const buildInvalidCommandUsage: (command: string, usage: string, summary: string, hint?: string[]) => string;
1
2
  export declare const conditionsAndPolicyMessage: string;
2
3
  export declare const listCommandDescription: string;
3
4
  export declare const showCommandDescription: string;
@@ -7,3 +8,4 @@ export declare const buildGeneratedAppNextStepsMessageBlocks: (name: string, app
7
8
  styled: string;
8
9
  }[];
9
10
  export declare const buildGeneratedAppNextStepsMessage: (name: string, appPath: string) => string;
11
+ export declare const wrapError: (message: string) => string;
@@ -1,19 +1,29 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.buildGeneratedAppNextStepsMessage = exports.buildGeneratedAppNextStepsMessageBlocks = exports.useCommandDescription = exports.showCommandDescription = exports.listCommandDescription = exports.conditionsAndPolicyMessage = void 0;
3
+ exports.wrapError = exports.buildGeneratedAppNextStepsMessage = exports.buildGeneratedAppNextStepsMessageBlocks = exports.useCommandDescription = exports.showCommandDescription = exports.listCommandDescription = exports.conditionsAndPolicyMessage = exports.buildInvalidCommandUsage = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const chalk_1 = tslib_1.__importDefault(require("chalk"));
6
6
  const buildCommandDescription = (command, subCommands) => {
7
7
  return (0, chalk_1.default) `
8
- Use the ${chalk_1.default.bgCyanBright(command)} command if you want to display some of your resources
8
+ Use the ${chalk_1.default.bgCyanBright.black(command)} command if you want to display some of your resources
9
9
  like the ${subCommands.join(' or ')} that you've created.
10
10
  The current available ressources are:
11
11
  ${subCommands.map((sc) => `\t- ${chalk_1.default.cyanBright(sc)}`).join('\n')}
12
12
  See the command examples in the help:
13
13
 
14
- ${chalk_1.default.bgWhite(`$ affinidi ${command} --help`)}
14
+ ${chalk_1.default.bgWhite.black(`$ affinidi ${command} --help`)}
15
15
  `;
16
16
  };
17
+ const buildInvalidCommandUsage = (command, usage, summary, hint) => {
18
+ return chalk_1.default.white ` "${command}" requires at least 1 argument${hint ? ` (${hint.join(',')})` : ''}.
19
+ See "${command} --help"
20
+
21
+ Usage: ${chalk_1.default.bold(`$ affinidi ${usage}`)}
22
+
23
+ ${summary}
24
+ `;
25
+ };
26
+ exports.buildInvalidCommandUsage = buildInvalidCommandUsage;
17
27
  exports.conditionsAndPolicyMessage = `
18
28
  Please confirm that you agree with:
19
29
  Terms and Conditions: ${chalk_1.default.blue('https://build.affinidi.com/dev-tools/terms-of-use.pdf')}
@@ -23,7 +33,7 @@ exports.conditionsAndPolicyMessage = `
23
33
  exports.listCommandDescription = buildCommandDescription('list', ['schemas', 'projects']);
24
34
  exports.showCommandDescription = buildCommandDescription('show', ['schema', 'project']);
25
35
  exports.useCommandDescription = (0, chalk_1.default) `
26
- Use the ${chalk_1.default.bgCyanBright('use')} command if you want to select a project you want to work on.
36
+ Use the ${chalk_1.default.bgCyanBright.black('use')} command if you want to select a project you want to work on.
27
37
  See the command examples in the help:
28
38
 
29
39
  ${chalk_1.default.bgWhite(`$ affinidi use --help`)}
@@ -63,4 +73,8 @@ const buildGeneratedAppNextStepsMessage = (name, appPath) => {
63
73
  .join('\n\n');
64
74
  };
65
75
  exports.buildGeneratedAppNextStepsMessage = buildGeneratedAppNextStepsMessage;
76
+ const wrapError = (message) => {
77
+ return chalk_1.default.red(`Error: ${message}`);
78
+ };
79
+ exports.wrapError = wrapError;
66
80
  //# sourceMappingURL=texts.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"texts.js","sourceRoot":"","sources":["../../src/render/texts.ts"],"names":[],"mappings":";;;;AAAA,0DAAyB;AAEzB,MAAM,uBAAuB,GAAG,CAAC,OAAe,EAAE,WAAqB,EAAU,EAAE;IACjF,OAAO,IAAA,eAAK,EAAA;YACF,eAAK,CAAC,YAAY,CAAC,OAAO,CAAC;aAC1B,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC;;IAEjC,WAAW,CAAC,GAAG,CAAC,CAAC,EAAU,EAAE,EAAE,CAAC,OAAO,eAAK,CAAC,UAAU,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;;;IAGzE,eAAK,CAAC,OAAO,CAAC,cAAc,OAAO,SAAS,CAAC;GAC9C,CAAA;AACH,CAAC,CAAA;AAEY,QAAA,0BA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C,CAAC,MAAM,CAAC;SACpB,IAAI,CAAC,MAAM,CAAC,CAAA;AACjB,CAAC,CAAA;AAJY,QAAA,iCAAiC,qCAI7C;AAEM,MAAM,SAAS,GAAG,CAAC,OAAe,EAAU,EAAE;IACnD,OAAO,eAAK,CAAC,GAAG,CAAC,UAAU,OAAO,EAAE,CAAC,CAAA;AACvC,CAAC,CAAA;AAFY,QAAA,SAAS,aAErB"}
@@ -19,7 +19,7 @@ class IAmService {
19
19
  return result.data;
20
20
  }
21
21
  catch (error) {
22
- return (0, errors_1.handleErrors)(new errors_1.CliError(error === null || error === void 0 ? void 0 : error.message, error.response.status, SERVICE));
22
+ throw new errors_1.CliError(error === null || error === void 0 ? void 0 : error.message, error.response.status, SERVICE);
23
23
  }
24
24
  };
25
25
  this.getProjectSummary = async (token, projectId) => {
@@ -34,7 +34,7 @@ class IAmService {
34
34
  return projectDetails;
35
35
  }
36
36
  catch (error) {
37
- return (0, errors_1.handleErrors)(new errors_1.CliError(error === null || error === void 0 ? void 0 : error.message, error.response.status, SERVICE));
37
+ throw new errors_1.CliError(error === null || error === void 0 ? void 0 : error.message, error.response.status, SERVICE);
38
38
  }
39
39
  };
40
40
  this.listProjects = async (token, skip, limit) => {
@@ -49,7 +49,7 @@ class IAmService {
49
49
  return resp.data.projects.slice(skip, skip + limit);
50
50
  }
51
51
  catch (error) {
52
- return (0, errors_1.handleErrors)(new errors_1.CliError(error === null || error === void 0 ? void 0 : error.message, error.response.status, SERVICE));
52
+ throw new errors_1.CliError(error === null || error === void 0 ? void 0 : error.message, error.response.status, SERVICE);
53
53
  }
54
54
  };
55
55
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/services/iam/index.ts"],"names":[],"mappings":";;;AAAA,yCAAqD;AACrD,uCAAyF;AAE5E,QAAA,OAAO,GAAG,uDAAuD,CAAA;AAC9E,MAAM,OAAO,GAAG,KAAK,CAAA;AAErB,MAAM,UAAU;IACd,YACmB,SAAS,IA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B,IAAI;gBACF,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,YAAY,CAAC;oBACnD,OAAO,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,EAAE,kBAAkB,EAAE;iBAC3F,CAAC,CAAA;gBACF,MAAM,gBAAgB,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAA;gBAClD,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,IAAI,GAAG,gBAAgB,EAAE;oBACzC,OAAO,EAAE,CAAA;iBACV;gBACD,OAAO,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,GAAG,KAAK,CAAC,CAAA;aACpD;YAAC,OAAO,KAAU,EAAE;gBACnB,MAAM,IAAI,iBAAQ,CAAC,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,OAAO,EAAE,KAAK,CAAC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;aACnE;QACH,CAAC,CAAA;IArDE,CAAC;CAsDL;AAED,MAAM,UAAU,GAAG,IAAI,UAAU,EAAE,CAAA;AAE1B,gCAAU"}
@@ -24,7 +24,7 @@ class IssuanceService {
24
24
  return resp.data;
25
25
  }
26
26
  catch (error) {
27
- return (0, errors_1.handleErrors)(new errors_1.CliError(error === null || error === void 0 ? void 0 : error.message, error.response.status, SERVICE));
27
+ throw new errors_1.CliError(error === null || error === void 0 ? void 0 : error.message, error.response.status, SERVICE);
28
28
  }
29
29
  };
30
30
  this.createOffer = async (apiKey, issuanceId, offerInput) => {
@@ -35,7 +35,7 @@ class IssuanceService {
35
35
  return resp.data;
36
36
  }
37
37
  catch (error) {
38
- return (0, errors_1.handleErrors)(new errors_1.CliError(error === null || error === void 0 ? void 0 : error.message, error.response.status, SERVICE));
38
+ throw new errors_1.CliError(error === null || error === void 0 ? void 0 : error.message, error.response.status, SERVICE);
39
39
  }
40
40
  };
41
41
  this.createFromCsv = async (apiKey, data) => {
@@ -47,7 +47,7 @@ class IssuanceService {
47
47
  return resp.data.issuance;
48
48
  }
49
49
  catch (error) {
50
- return (0, errors_1.handleErrors)(new errors_1.CliError(error === null || error === void 0 ? void 0 : error.message, (_a = error.response) === null || _a === void 0 ? void 0 : _a.status, SERVICE));
50
+ throw new errors_1.CliError(error === null || error === void 0 ? void 0 : error.message, (_a = error.response) === null || _a === void 0 ? void 0 : _a.status, SERVICE);
51
51
  }
52
52
  };
53
53
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/services/issuance/index.ts"],"names":[],"mappings":";;;AACA,yCAAqD;AACrD,iDAMuB;AACvB,yDAA4C;AAE/B,QAAA,YAAY,GAAG,8DAA8D,CAAA;AAC1F,MAAM,OAAO,GAAG,UAAU,CAAA;AAE1B,MAAM,eAAe;IACnB,YACmB,SAAS,IAAI,kBAAW,CAAC;QACxC,OAAO,EAAE,oBAAY;QACrB,eAAe,EAAE,IAAI;KACtB,CAAC,EACe,aAAa,IAAI,0BAAO,CAAC;QACxC,OAAO,EAAE,oBAAY;QACrB,eAAe,EAAE,IAAI;KACtB,CAAC;QAPe,WAAM,GAAN,MAAM,CAGrB;QACe,eAAU,GAAV,UAAU,CAGzB;QAGG,mBAAc,GAAG,KAAK,EAC3B,MAAc,EACd,aAAkC,EACH,EAAE;YACjC,IAAI;gBACF,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,aAAa,EAAE;oBACrE,OAAO,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE;iBAC/B,CAAC,CAAA;gBACF,OAAO,IAAI,CAAC,IAAI,CAAA;aACjB;YAAC,OAAO,KAAU,EAAE;gBACnB,OAAO,IAAA,qBAAY,EAAC,IAAI,iBAAQ,CAAC,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,OAAO,EAAE,KAAK,CAAC,QAAQ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K,aAAL,KAAK,uBAAL,KAAK,CAAE,OAAO,EAAE,KAAK,CAAC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;aACnE;QACH,CAAC,CAAA;QAEM,kBAAa,GAAG,KAAK,EAAE,MAAc,EAAE,IAAc,EAAiC,EAAE;;YAC7F,IAAI;gBACF,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,iBAAiB,CAAC,IAAI,EAAE;oBACvE,OAAO,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE;iBAC/B,CAAC,CAAA;gBACF,OAAO,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAA;aAC1B;YAAC,OAAO,KAAU,EAAE;gBACnB,MAAM,IAAI,iBAAQ,CAAC,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,OAAO,EAAE,MAAA,KAAK,CAAC,QAAQ,0CAAE,MAAM,EAAE,OAAO,CAAC,CAAA;aACpE;QACH,CAAC,CAAA;IAxCE,CAAC;CAyCL;AAED,MAAM,eAAe,GAAG,IAAI,eAAe,EAAE,CAAA;AAEpC,0CAAe"}
@@ -0,0 +1,2 @@
1
+ import { SchemaField, SchemaHeaderField, VcJsonLdContext } from './types';
2
+ export declare const generateContext: (header: SchemaHeaderField, fields: SchemaField[]) => VcJsonLdContext;
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generateContext = void 0;
4
+ const types_1 = require("./types");
5
+ const SCHEMA_ORG_BASE_URL = 'https://schema.org/';
6
+ const mapType = (type) => {
7
+ if (type === types_1.SchemaFieldType.DID)
8
+ return '@id';
9
+ if (type === types_1.SchemaFieldType.Object)
10
+ return '';
11
+ return `${SCHEMA_ORG_BASE_URL}${type}`;
12
+ };
13
+ const buildJsonLdContext = (header, context) => ({
14
+ '@context': {
15
+ [header.type]: {
16
+ '@id': header.jsonLdContextUrl,
17
+ '@context': { '@version': 1.1, '@protected': true },
18
+ },
19
+ ...context,
20
+ },
21
+ });
22
+ const buildContextFromFields = (fields) => fields.reduce((res, e) => ({
23
+ ...res,
24
+ ...buildCredentialSubjectField(e),
25
+ }), {});
26
+ const buildCredentialSubjectField = (field) => {
27
+ const billet = { [field.name]: { '@id': `schema-id:${field.name}` } };
28
+ if (field.type !== types_1.SchemaFieldType.Object) {
29
+ Object.assign(billet[field.name], { '@type': mapType(field.type) });
30
+ }
31
+ else {
32
+ const subContext = buildContextFromFields(field.nested || []);
33
+ Object.assign(billet[field.name], { '@context': subContext });
34
+ }
35
+ return billet;
36
+ };
37
+ const generateContext = (header, fields) => {
38
+ const context = buildContextFromFields(fields);
39
+ return buildJsonLdContext(header, context);
40
+ };
41
+ exports.generateContext = generateContext;
42
+ //# sourceMappingURL=context-generator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context-generator.js","sourceRoot":"","sources":["../../../../src/services/schema-manager/generator/context-generator.ts"],"names":[],"mappings":";;;AAAA,mCAMgB;AAEhB,MAAM,mBAAmB,GAAG,qBAAqB,CAAA;AAEjD,MAAM,OAAO,GAAG,CAAC,IAAqB,EAAU,EAAE;IAChD,IAAI,IAAI,KAAK,uBAAe,CAAC,GAAG;QAAE,OAAO,KAAK,CAAA;IAC9C,IAAI,IAAI,KAAK,uBAAe,CAAC,MAAM;QAAE,OAAO,EAAE,CAAA;IAC9C,OAAO,GAAG,mBAAmB,GAAG,IAAI,EAAE,CAAA;AACxC,CAAC,CAAA;AAED,MAAM,kBAAkB,GAAG,CACzB,MAAyB,EACzB,OAA8C,EAC7B,EAAE,CAAC,CAAC;IACrB,UAAU,EAAE;QACV,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE;YACb,KAAK,EAAE,MAAM,CAAC,gBAAgB;YAC9B,UAAU,EAAE,EAAE,UAAU,EAAE,GAAG,EAAE,YAAY,EAAE,IAAI,EAAE;SAC5B;QACzB,GAAG,OAAO;KACX;CACF,CAAC,CAAA;AAEF,MAAM,sBAAsB,GAAG,CAAC,MAAqB,EAAE,EAAE,CACvD,MAAM,CAAC,MAAM,CACX,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;IACX,GAAG,GAAG;IACN,GAAG,2BAA2B,CAAC,CAAC,CAAC;CAClC,CAAC,EACF,EAAE,CACH,CAAA;AAEH,MAAM,2BAA2B,GAAG,CAAC,KAAkB,EAAE,EAAE;IACzD,MAAM,MAAM,GAAG,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,EAAE,KAAK,EAAE,aAAa,KAAK,CAAC,IAAI,EAAE,EAAE,EAAE,CAAA;IACrE,IAAI,KAAK,CAAC,IAAI,KAAK,uBAAe,CAAC,MAAM,EAAE;QACzC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;KACpE;SAAM;QACL,MAAM,UAAU,GAAG,sBAAsB,CAAC,KAAK,CAAC,MAAM,IAAI,EAAE,CAAC,CAAA;QAE7D,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,EAAE,UAAU,EAAE,UAAU,EAAE,CAAC,CAAA;KAC9D;IAED,OAAO,MAAM,CAAA;AACf,CAAC,CAAA;AAEM,MAAM,eAAe,GAAG,CAC7B,MAAyB,EACzB,MAAqB,EACJ,EAAE;IACnB,MAAM,OAAO,GAAG,sBAAsB,CAAC,MAAM,CAAC,CAAA;IAC9C,OAAO,kBAAkB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;AAC5C,CAAC,CAAA;AANY,QAAA,eAAe,mBAM3B"}
@@ -0,0 +1,22 @@
1
+ import { SchemaField, SchemaHeaderField } from './types';
2
+ export interface Options {
3
+ namespace?: string;
4
+ type: string;
5
+ version: number;
6
+ revision: number;
7
+ }
8
+ export declare const generateSchemaId: ({ namespace, type, version, revision }: Options) => string;
9
+ export declare const getNextVersion: ({ version, revision }: {
10
+ version: number;
11
+ revision: number;
12
+ }) => number[];
13
+ export declare const generateSchemaFilesMetadata: (host: string, schemaId: string) => {
14
+ jsonSchemaFilename: string;
15
+ jsonLdContextFilename: string;
16
+ jsonSchemaUrl: string;
17
+ jsonLdContextUrl: string;
18
+ };
19
+ export declare const generate: (header: SchemaHeaderField, fields: SchemaField[]) => {
20
+ jsonSchema: import("./types").VcJsonSchema;
21
+ jsonLdContext: import("./types").VcJsonLdContext;
22
+ };
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generate = exports.generateSchemaFilesMetadata = exports.getNextVersion = exports.generateSchemaId = void 0;
4
+ const context_generator_1 = require("./context-generator");
5
+ const schema_generator_1 = require("./schema-generator");
6
+ const generateSchemaId = ({ namespace, type, version, revision }) => {
7
+ const namespacePart = namespace ? `@${namespace}/` : '';
8
+ return `${namespacePart}${type}V${version}-${revision}`;
9
+ };
10
+ exports.generateSchemaId = generateSchemaId;
11
+ const getNextVersion = ({ version, revision }) => revision === 999 ? [version + 1, 0] : [version, revision + 1];
12
+ exports.getNextVersion = getNextVersion;
13
+ const generateSchemaFilesMetadata = (host, schemaId) => {
14
+ const jsonSchemaFilename = `${schemaId}.json`;
15
+ const jsonLdContextFilename = `${schemaId}.jsonld`;
16
+ return {
17
+ jsonSchemaFilename,
18
+ jsonLdContextFilename,
19
+ jsonSchemaUrl: `${host}/${jsonSchemaFilename}`,
20
+ jsonLdContextUrl: `${host}/${jsonLdContextFilename}`,
21
+ };
22
+ };
23
+ exports.generateSchemaFilesMetadata = generateSchemaFilesMetadata;
24
+ const generate = (header, fields) => ({
25
+ jsonSchema: (0, schema_generator_1.generateSchema)(header, fields),
26
+ jsonLdContext: (0, context_generator_1.generateContext)(header, fields),
27
+ });
28
+ exports.generate = generate;
29
+ //# sourceMappingURL=helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../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AA;AAHW,QAAA,QAAQ,YAGnB"}
@@ -0,0 +1,6 @@
1
+ import { SchemaFieldType, VcJsonSchemaProperty } from './types';
2
+ export declare const mapSchemaFieldType: (type: SchemaFieldType) => {
3
+ type: string;
4
+ format?: string;
5
+ };
6
+ export declare const mapVcSchemaJsonType: ({ type, format }: VcJsonSchemaProperty) => SchemaFieldType;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.mapVcSchemaJsonType = exports.mapSchemaFieldType = void 0;
4
+ const types_1 = require("./types");
5
+ const schemaFieldTypeMapping = {
6
+ [types_1.SchemaFieldType.Text]: { type: 'string' },
7
+ [types_1.SchemaFieldType.DID]: { type: 'string', format: 'did' },
8
+ [types_1.SchemaFieldType.URI]: { type: 'string', format: 'uri' },
9
+ [types_1.SchemaFieldType.Date]: { type: 'string', format: 'date' },
10
+ [types_1.SchemaFieldType.DateTime]: { type: 'string', format: 'date-time' },
11
+ [types_1.SchemaFieldType.Number]: { type: 'number' },
12
+ [types_1.SchemaFieldType.Boolean]: { type: 'boolean' },
13
+ [types_1.SchemaFieldType.Object]: { type: 'object' },
14
+ };
15
+ const mapSchemaFieldType = (type) => schemaFieldTypeMapping[type];
16
+ exports.mapSchemaFieldType = mapSchemaFieldType;
17
+ const mapVcSchemaJsonType = ({ type, format }) => {
18
+ var _a;
19
+ return (_a = Object.entries(schemaFieldTypeMapping).find(([, v]) => v.type === type && v.format === format)) === null || _a === void 0 ? void 0 : _a[0];
20
+ };
21
+ exports.mapVcSchemaJsonType = mapVcSchemaJsonType;
22
+ //# sourceMappingURL=mapping.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mapping.js","sourceRoot":"","sources":["../../../../src/services/schema-manager/generator/mapping.ts"],"names":[],"mappings":";;;AAAA,mCAA+D;AAE/D,MAAM,sBAAsB,GAA+D;IACzF,CAAC,uBAAe,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,EAAE,QAAQ,EAA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+1,103 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generateSchema = void 0;
4
+ const types_1 = require("./types");
5
+ const mapping_1 = require("./mapping");
6
+ const buildSchema = (header, credentialSubject) => {
7
+ var _a;
8
+ return ({
9
+ $schema: 'http://json-schema.org/draft-07/schema#',
10
+ $id: header.jsonSchemaUrl,
11
+ $metadata: {
12
+ version: header.version,
13
+ revision: header.revision,
14
+ discoverable: (_a = header.discoverable) !== null && _a !== void 0 ? _a : true,
15
+ uris: {
16
+ jsonLdContext: header.jsonLdContextUrl,
17
+ jsonSchema: header.jsonSchemaUrl,
18
+ },
19
+ },
20
+ title: header.type,
21
+ description: header.description,
22
+ type: 'object',
23
+ required: ['@context', 'type', 'issuer', 'issuanceDate', 'credentialSubject'],
24
+ properties: {
25
+ '@context': {
26
+ type: ['string', 'array', 'object'],
27
+ },
28
+ id: {
29
+ type: 'string',
30
+ format: 'uri',
31
+ },
32
+ type: {
33
+ type: ['string', 'array'],
34
+ items: {
35
+ type: 'string',
36
+ },
37
+ },
38
+ issuer: {
39
+ type: ['string', 'object'],
40
+ format: 'uri',
41
+ required: ['id'],
42
+ properties: {
43
+ id: {
44
+ type: 'string',
45
+ format: 'uri',
46
+ },
47
+ },
48
+ },
49
+ issuanceDate: {
50
+ type: 'string',
51
+ format: 'date-time',
52
+ },
53
+ expirationDate: {
54
+ type: 'string',
55
+ format: 'date-time',
56
+ },
57
+ credentialSubject,
58
+ credentialSchema: {
59
+ type: 'object',
60
+ required: ['id', 'type'],
61
+ properties: {
62
+ id: {
63
+ type: 'string',
64
+ format: 'uri',
65
+ },
66
+ type: {
67
+ type: 'string',
68
+ },
69
+ },
70
+ },
71
+ },
72
+ });
73
+ };
74
+ const buildCredentialSubjectPropertiesFromFields = (fields) => {
75
+ var _a, _b;
76
+ return (_b = (_a = fields === null || fields === void 0 ? void 0 : fields.reduce) === null || _a === void 0 ? void 0 : _a.call(fields, (res, field) => ({
77
+ ...res,
78
+ [field.name]: buildCredentialSubjectField(field),
79
+ }), {})) !== null && _b !== void 0 ? _b : {};
80
+ };
81
+ const buildCredentialSubjectField = (field) => {
82
+ var _a;
83
+ const { name, description, type, nested } = field;
84
+ const property = {
85
+ title: name,
86
+ ...(0, mapping_1.mapSchemaFieldType)(type),
87
+ ...(typeof description === 'string' && { description }),
88
+ };
89
+ if (type !== types_1.SchemaFieldType.Object) {
90
+ return property;
91
+ }
92
+ const subProperties = buildCredentialSubjectPropertiesFromFields(nested);
93
+ const required = ((_a = nested === null || nested === void 0 ? void 0 : nested.filter) === null || _a === void 0 ? void 0 : _a.call(nested, (e) => e.required).map((e) => e.name)) || [];
94
+ return { ...property, properties: subProperties, required };
95
+ };
96
+ const generateSchema = (header, fields) => {
97
+ const properties = buildCredentialSubjectPropertiesFromFields(fields);
98
+ const required = fields.filter((e) => e.required).map((e) => e.name);
99
+ const credentialSubject = { type: 'object', properties, required };
100
+ return buildSchema(header, credentialSubject);
101
+ };
102
+ exports.generateSchema = generateSchema;
103
+ //# sourceMappingURL=schema-generator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema-generator.js","sourceRoot":"","sources":["../../../../src/services/schema-manager/generator/schema-generator.ts"],"names":[],"mappings":";;;AAAA,mCAOgB;AAChB,uCAA8C;AAE9C,MAAM,WAAW,GAAG,CAClB,MAAyB,EACzB,iBAAgD,EAClC,EAAE;;IAAC,OAAA,CAAC;QAClB,OAAO,EAAE,yCAAyC;QAClD,GAAG,EAAE,MAAM,CAAC,aAAa;QACzB,SAAS,EAAE;YACT,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,QAAQ,EAAE,MAAM,CAAC,QAAQ;YACzB,YAAY,EAAE,MAAA,MAAM,CAAC,YAAY,mCAAI,IAAI;YACzC,IAAI,EAAE;gBACJ,aAAa,EAAE,MAAM,CAAC,gBAAgB;gBACtC,UAAU,EAAE,MAAM,CAAC,aAAa;aACjC;SACF;QACD,KAAK,EAAE,MAAM,CAAC,IAAI;Q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C,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAA;IAEpE,MAAM,iBAAiB,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,CAAA;IAElE,OAAO,WAAW,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAA;AAC/C,CAAC,CAAA;AAPY,QAAA,cAAc,kBAO1B"}
@@ -0,0 +1,87 @@
1
+ export declare enum SchemaFieldType {
2
+ DID = "did",
3
+ Text = "Text",
4
+ URI = "URL",
5
+ Date = "Date",
6
+ DateTime = "DateTime",
7
+ Number = "Number",
8
+ Boolean = "Boolean",
9
+ Object = "object"
10
+ }
11
+ /**
12
+ * schemasHostingPath - the url path to the place where the schema will be hosted if public,
13
+ * e.g.: https://public.schemas.affinidi.com/${schema-slug}
14
+ * so, when GET request is made to this path the service will return this schema
15
+ */
16
+ export declare type SchemaHeaderField = {
17
+ discoverable?: boolean;
18
+ type: string;
19
+ description: string;
20
+ version: number;
21
+ revision: number;
22
+ jsonSchemaUrl: string;
23
+ jsonLdContextUrl: string;
24
+ };
25
+ export declare type SchemaField = {
26
+ name: string;
27
+ type: SchemaFieldType;
28
+ required: boolean;
29
+ description?: string;
30
+ nested?: SchemaField[];
31
+ };
32
+ export declare type GeneratorInputParams = {
33
+ header: SchemaHeaderField;
34
+ fields: SchemaField[];
35
+ };
36
+ export declare type VcJsonLdContextField = {
37
+ '@id': string;
38
+ '@type': string;
39
+ '@context'?: {
40
+ '@version'?: number;
41
+ '@protected'?: boolean;
42
+ [k: string]: number | boolean | VcJsonLdContextField | undefined;
43
+ };
44
+ };
45
+ export declare type VcJsonLdContext = {
46
+ '@context': {
47
+ [k: string]: VcJsonLdContextField;
48
+ };
49
+ };
50
+ export declare type VcJsonSchemeCredentialSubject = {
51
+ required?: string[];
52
+ properties: {
53
+ [k: string]: VcJsonSchemaProperty;
54
+ };
55
+ [k: string]: any;
56
+ };
57
+ export declare type VcJsonSchemaProperty = {
58
+ title: string;
59
+ type: string;
60
+ format?: string;
61
+ description?: string;
62
+ required?: string[];
63
+ properties?: {
64
+ [k: string]: VcJsonSchemaProperty;
65
+ };
66
+ };
67
+ export declare type VcJsonSchema = {
68
+ title: string;
69
+ description: string;
70
+ $id: string;
71
+ $metadata: {
72
+ version: number;
73
+ revision: number;
74
+ discoverable: boolean;
75
+ uris: {
76
+ jsonLdContext: string;
77
+ jsonSchema: string;
78
+ [k: string]: any;
79
+ };
80
+ [k: string]: any;
81
+ };
82
+ properties: {
83
+ credentialSubject: VcJsonSchemeCredentialSubject;
84
+ [k: string]: any;
85
+ };
86
+ [k: string]: any;
87
+ };
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SchemaFieldType = void 0;
4
+ var SchemaFieldType;
5
+ (function (SchemaFieldType) {
6
+ SchemaFieldType["DID"] = "did";
7
+ SchemaFieldType["Text"] = "Text";
8
+ SchemaFieldType["URI"] = "URL";
9
+ SchemaFieldType["Date"] = "Date";
10
+ SchemaFieldType["DateTime"] = "DateTime";
11
+ SchemaFieldType["Number"] = "Number";
12
+ SchemaFieldType["Boolean"] = "Boolean";
13
+ SchemaFieldType["Object"] = "object";
14
+ })(SchemaFieldType = exports.SchemaFieldType || (exports.SchemaFieldType = {}));
15
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/services/schema-manager/generator/types.ts"],"names":[],"mappings":";;;AAAA,IAAY,eASX;AATD,WAAY,eAAe;IACzB,8BAAW,CAAA;IACX,gCAAa,CAAA;IACb,8BAAW,CAAA;IACX,gCAAa,CAAA;IACb,wCAAqB,CAAA;IACrB,oCAAiB,CAAA;IACjB,sCAAmB,CAAA;IACnB,oCAAiB,CAAA;AACnB,CAAC,EATW,eAAe,GAAf,uBAAe,KAAf,uBAAe,QAS1B"}
@@ -1,4 +1,4 @@
1
- import { Api as SchemaManagerApi, SchemaDto } from './schema-manager.api';
1
+ import { Api as SchemaManagerApi, CreateSchemaInputDto, SchemaDto } from './schema-manager.api';
2
2
  export declare const SCHEMA_MANAGER_URL = "https://affinidi-schema-manager.prod.affinity-project.org/api/v1";
3
3
  export declare type ScopeType = 'public' | 'unlisted' | 'default';
4
4
  declare class SchemaManagerService {
@@ -14,6 +14,16 @@ declare class SchemaManagerService {
14
14
  limit: number;
15
15
  }) => Promise<SchemaDto[]>;
16
16
  getById: (id: string, apiKey: string) => Promise<SchemaDto>;
17
+ createSchema: (apiKey: string, schemaInput: CreateSchemaInputDto) => Promise<SchemaDto>;
18
+ generateNextVersion: ({ type, scope }: {
19
+ type: string;
20
+ scope: ScopeType;
21
+ }, { apiKey, authorDid, limit, skip, }: {
22
+ apiKey: string;
23
+ authorDid: string;
24
+ limit: number;
25
+ skip: number;
26
+ }) => Promise<number[]>;
17
27
  }
18
28
  export declare const schemaManagerService: SchemaManagerService;
19
29
  export {};
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.schemaManagerService = exports.SCHEMA_MANAGER_URL = void 0;
4
4
  const http_status_codes_1 = require("http-status-codes");
5
+ const helpers_1 = require("./generator/helpers");
5
6
  const schema_manager_api_1 = require("./schema-manager.api");
6
7
  const errors_1 = require("../../errors");
7
8
  exports.SCHEMA_MANAGER_URL = 'https://affinidi-schema-manager.prod.affinity-project.org/api/v1';
@@ -26,7 +27,7 @@ class SchemaManagerService {
26
27
  return response.data.schemas;
27
28
  }
28
29
  catch (err) {
29
- return (0, errors_1.handleErrors)(new errors_1.CliError(err === null || err === void 0 ? void 0 : err.message, err.response.status, SERVICE));
30
+ throw new errors_1.CliError(err === null || err === void 0 ? void 0 : err.message, err.response.status, SERVICE);
30
31
  }
31
32
  };
32
33
  this.getById = async (id, apiKey) => {
@@ -34,9 +35,30 @@ class SchemaManagerService {
34
35
  return (await this.client.schemas.getSchema(id, { headers: { 'API-KEY': apiKey } })).data;
35
36
  }
36
37
  catch (error) {
37
- return (0, errors_1.handleErrors)(new errors_1.CliError(error === null || error === void 0 ? void 0 : error.message, error.response.status, SERVICE));
38
+ throw new errors_1.CliError(error === null || error === void 0 ? void 0 : error.message, error.response.status, SERVICE);
38
39
  }
39
40
  };
41
+ this.createSchema = async (apiKey, schemaInput) => {
42
+ try {
43
+ return (await this.client.schemas.createSchema(schemaInput, { headers: { 'API-KEY': apiKey } })).data;
44
+ }
45
+ catch (error) {
46
+ throw new errors_1.CliError(error === null || error === void 0 ? void 0 : error.message, error.response.status, SERVICE);
47
+ }
48
+ };
49
+ this.generateNextVersion = async ({ type, scope }, { apiKey = null, authorDid = null, limit = 1, skip = 0, }) => {
50
+ const schemas = await this.client.schemas.searchSchemas({ scope, skip, limit, type, did: authorDid }, {
51
+ headers: {
52
+ 'API-KEY': apiKey,
53
+ },
54
+ });
55
+ return schemas.data.count
56
+ ? (0, helpers_1.getNextVersion)({
57
+ version: schemas.data.schemas[0].version,
58
+ revision: schemas.data.schemas[0].revision,
59
+ })
60
+ : [1, 0];
61
+ };
40
62
  }
41
63
  }
42
64
  exports.schemaManagerService = new SchemaManagerService();