@digipair/skill-editor 0.63.1 → 0.64.2

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/index.cjs.js CHANGED
@@ -3,6 +3,7 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var fs = require('fs');
6
+ var promises = require('fs/promises');
6
7
 
7
8
  function _extends() {
8
9
  _extends = Object.assign || function assign(target) {
@@ -15163,6 +15164,21 @@ let EditorService = class EditorService {
15163
15164
  const templates = entries.filter((entry)=>entry.isDirectory()).map((entry)=>entry.name);
15164
15165
  return templates;
15165
15166
  }
15167
+ async schemas(params, _pinsSettingsList, _context) {
15168
+ const { libraries, language } = params;
15169
+ const list = Promise.all(Object.keys(libraries).map(async (library)=>{
15170
+ let modulePath = require.resolve(`${library}`);
15171
+ modulePath = modulePath.substring(0, modulePath.lastIndexOf('/'));
15172
+ let schemasPath = modulePath + '/schema.json';
15173
+ if (language !== 'en') {
15174
+ try {
15175
+ schemasPath = modulePath + `/schema.${language}.json`;
15176
+ } catch (e) {}
15177
+ }
15178
+ return JSON.parse(await promises.readFile(schemasPath, 'utf8'));
15179
+ }));
15180
+ return list;
15181
+ }
15166
15182
  };
15167
15183
  const setReasoning = (params, pinsSettingsList, context)=>new EditorService().setReasoning(params, pinsSettingsList, context);
15168
15184
  const reasonings = (params, pinsSettingsList, context)=>new EditorService().reasonings(params, pinsSettingsList, context);
@@ -15175,6 +15191,7 @@ const removeDigipair = (params, pinsSettingsList, context)=>new EditorService().
15175
15191
  const addDigipair = (params, pinsSettingsList, context)=>new EditorService().addDigipair(params, pinsSettingsList, context);
15176
15192
  const metadata = (params, pinsSettingsList, context)=>new EditorService().metadata(params, pinsSettingsList, context);
15177
15193
  const templates = (params, pinsSettingsList, context)=>new EditorService().templates(params, pinsSettingsList, context);
15194
+ const schemas = (params, pinsSettingsList, context)=>new EditorService().schemas(params, pinsSettingsList, context);
15178
15195
 
15179
15196
  exports.addDigipair = addDigipair;
15180
15197
  exports.digipair = digipair;
@@ -15184,6 +15201,7 @@ exports.reasoning = reasoning;
15184
15201
  exports.reasonings = reasonings;
15185
15202
  exports.removeDigipair = removeDigipair;
15186
15203
  exports.removeReasoning = removeReasoning;
15204
+ exports.schemas = schemas;
15187
15205
  exports.setDigipair = setDigipair;
15188
15206
  exports.setReasoning = setReasoning;
15189
15207
  exports.templates = templates;
package/index.esm.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { promises, existsSync } from 'fs';
2
+ import { readFile } from 'fs/promises';
2
3
 
3
4
  function _extends() {
4
5
  _extends = Object.assign || function assign(target) {
@@ -15159,6 +15160,21 @@ let EditorService = class EditorService {
15159
15160
  const templates = entries.filter((entry)=>entry.isDirectory()).map((entry)=>entry.name);
15160
15161
  return templates;
15161
15162
  }
15163
+ async schemas(params, _pinsSettingsList, _context) {
15164
+ const { libraries, language } = params;
15165
+ const list = Promise.all(Object.keys(libraries).map(async (library)=>{
15166
+ let modulePath = require.resolve(`${library}`);
15167
+ modulePath = modulePath.substring(0, modulePath.lastIndexOf('/'));
15168
+ let schemasPath = modulePath + '/schema.json';
15169
+ if (language !== 'en') {
15170
+ try {
15171
+ schemasPath = modulePath + `/schema.${language}.json`;
15172
+ } catch (e) {}
15173
+ }
15174
+ return JSON.parse(await readFile(schemasPath, 'utf8'));
15175
+ }));
15176
+ return list;
15177
+ }
15162
15178
  };
15163
15179
  const setReasoning = (params, pinsSettingsList, context)=>new EditorService().setReasoning(params, pinsSettingsList, context);
15164
15180
  const reasonings = (params, pinsSettingsList, context)=>new EditorService().reasonings(params, pinsSettingsList, context);
@@ -15171,5 +15187,6 @@ const removeDigipair = (params, pinsSettingsList, context)=>new EditorService().
15171
15187
  const addDigipair = (params, pinsSettingsList, context)=>new EditorService().addDigipair(params, pinsSettingsList, context);
15172
15188
  const metadata = (params, pinsSettingsList, context)=>new EditorService().metadata(params, pinsSettingsList, context);
15173
15189
  const templates = (params, pinsSettingsList, context)=>new EditorService().templates(params, pinsSettingsList, context);
15190
+ const schemas = (params, pinsSettingsList, context)=>new EditorService().schemas(params, pinsSettingsList, context);
15174
15191
 
15175
- export { addDigipair, digipair, digipairs, metadata, reasoning, reasonings, removeDigipair, removeReasoning, setDigipair, setReasoning, templates };
15192
+ export { addDigipair, digipair, digipairs, metadata, reasoning, reasonings, removeDigipair, removeReasoning, schemas, setDigipair, setReasoning, templates };
@@ -10,3 +10,4 @@ export declare const removeDigipair: (params: any, pinsSettingsList: PinsSetting
10
10
  export declare const addDigipair: (params: any, pinsSettingsList: PinsSettings[], context: any) => Promise<{}>;
11
11
  export declare const metadata: (params: any, pinsSettingsList: PinsSettings[], context: any) => Promise<any>;
12
12
  export declare const templates: (params: any, pinsSettingsList: PinsSettings[], context: any) => Promise<string[]>;
13
+ export declare const schemas: (params: any, pinsSettingsList: PinsSettings[], context: any) => Promise<any[]>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digipair/skill-editor",
3
- "version": "0.63.1",
3
+ "version": "0.64.2",
4
4
  "dependencies": {},
5
5
  "main": "./index.cjs.js",
6
6
  "module": "./index.esm.js"
package/schema.fr.json CHANGED
@@ -362,6 +362,34 @@
362
362
  ],
363
363
  "x-events": []
364
364
  }
365
+ },
366
+ "/schemas": {
367
+ "post": {
368
+ "tags": ["service"],
369
+ "summary": "Liste des schemas",
370
+ "descriptions": "Liste des schemas pour les librairies fournies",
371
+ "parameters": [
372
+ {
373
+ "name": "libraries",
374
+ "summary": "Librairies",
375
+ "required": true,
376
+ "description": "Liste des librairies pour lesquelles on veut les schemas",
377
+ "schema": {
378
+ "type": "object"
379
+ }
380
+ },
381
+ {
382
+ "name": "language",
383
+ "summary": "Langue",
384
+ "required": true,
385
+ "description": "Langue des librairies",
386
+ "schema": {
387
+ "type": "string"
388
+ }
389
+ }
390
+ ],
391
+ "x-events": []
392
+ }
365
393
  }
366
394
  },
367
395
  "components": {
package/schema.json CHANGED
@@ -362,6 +362,34 @@
362
362
  ],
363
363
  "x-events": []
364
364
  }
365
+ },
366
+ "/schemas": {
367
+ "post": {
368
+ "tags": ["service"],
369
+ "summary": "List Schemas",
370
+ "descriptions": "Lists the schemas of the libraries",
371
+ "parameters": [
372
+ {
373
+ "name": "libraries",
374
+ "summary": "Libraries",
375
+ "required": true,
376
+ "description": "List of libraries",
377
+ "schema": {
378
+ "type": "object"
379
+ }
380
+ },
381
+ {
382
+ "name": "language",
383
+ "summary": "Language",
384
+ "required": true,
385
+ "description": "Language of the schema",
386
+ "schema": {
387
+ "type": "string"
388
+ }
389
+ }
390
+ ],
391
+ "x-events": []
392
+ }
365
393
  }
366
394
  },
367
395
  "components": {