@skmtc/core 0.0.507 → 0.0.508

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.
@@ -1 +1 @@
1
- {"version":3,"file":"handleEnrichment.d.ts","sourceRoot":"","sources":["../../src/run/handleEnrichment.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAA;AAetE,eAAO,MAAM,gBAAgB,GAAU,cAAc,0DAIlD,iBAAiB,CAAC,cAAc,CAAC,oBAyCnC,CAAA;AAGD,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC5D,GAAG,EAAE,CAAC,EACN,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,CAAC,CAAC,CAyBZ"}
1
+ {"version":3,"file":"handleEnrichment.d.ts","sourceRoot":"","sources":["../../src/run/handleEnrichment.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAA;AAetE,eAAO,MAAM,gBAAgB,GAAU,cAAc,0DAIlD,iBAAiB,CAAC,cAAc,CAAC,oBAqCnC,CAAA;AAGD,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC5D,GAAG,EAAE,CAAC,EACN,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,CAAC,CAAC,CAyBZ"}
@@ -13,7 +13,6 @@ export const handleEnrichment = async ({ prompt, content, responseSchema: zodRes
13
13
  const responseSchema = zodToJsonSchema(zodResponseSchema, {
14
14
  target: 'openApi3'
15
15
  });
16
- console.log('RESPONSE SCHEMA', responseSchema);
17
16
  const chatSession = model.startChat({
18
17
  generationConfig: {
19
18
  temperature: 1,
@@ -43,7 +42,6 @@ export const handleEnrichment = async ({ prompt, content, responseSchema: zodRes
43
42
  ]
44
43
  });
45
44
  const result = await chatSession.sendMessage(`${prompt}\n\n${content}`);
46
- console.log('RESULT', result);
47
45
  return result.response.text();
48
46
  };
49
47
  // deno-lint-ignore no-explicit-any
@@ -1 +1 @@
1
- {"version":3,"file":"toEnrichments.d.ts","sourceRoot":"","sources":["../../src/run/toEnrichments.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;AAC9D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AAI9D,KAAK,iBAAiB,CAAC,cAAc,IAAI;IACvC,UAAU,EAAE,aAAa,CAAC,cAAc,CAAC,EAAE,CAAA;IAC3C,WAAW,EAAE,WAAW,CAAA;CACzB,CAAA;AAED,MAAM,MAAM,cAAc,GAAG;IAC3B,GAAG,EAAE,MAAM,EAAE,CAAA;IACb,KAAK,EAAE,OAAO,CAAA;CACf,CAAA;AAED,eAAO,MAAM,aAAa,GAAU,cAAc,+BAG/C,iBAAiB,CAAC,cAAc,CAAC,8CA4CnC,CAAA"}
1
+ {"version":3,"file":"toEnrichments.d.ts","sourceRoot":"","sources":["../../src/run/toEnrichments.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;AAC9D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AAI9D,KAAK,iBAAiB,CAAC,cAAc,IAAI;IACvC,UAAU,EAAE,aAAa,CAAC,cAAc,CAAC,EAAE,CAAA;IAC3C,WAAW,EAAE,WAAW,CAAA;CACzB,CAAA;AAED,MAAM,MAAM,cAAc,GAAG;IAC3B,GAAG,EAAE,MAAM,EAAE,CAAA;IACb,KAAK,EAAE,OAAO,CAAA;CACf,CAAA;AAQD,eAAO,MAAM,aAAa,GAAU,cAAc,+BAG/C,iBAAiB,CAAC,cAAc,CAAC,8CA0DnC,CAAA"}
@@ -1,18 +1,16 @@
1
1
  import { handleEnrichment } from './handleEnrichment.js';
2
2
  export const toEnrichments = async ({ generators, oasDocument }) => {
3
- const output = {};
3
+ const responses = [];
4
4
  for (const generator of generators) {
5
5
  if (generator.type === 'operation') {
6
6
  for (const operation of oasDocument.operations) {
7
7
  const enrichmentRequest = generator.toEnrichmentRequest?.(operation);
8
8
  if (enrichmentRequest) {
9
- const enrichmentResponse = await handleEnrichment(enrichmentRequest);
10
- if (!output[generator.id]) {
11
- output[generator.id] = [];
12
- }
13
- output[generator.id].push({
9
+ const enrichmentResponse = handleEnrichment(enrichmentRequest);
10
+ responses.push({
11
+ generatorId: generator.id,
14
12
  key: ['operations', operation.path, operation.method, 'enrichments'],
15
- value: JSON.parse(enrichmentResponse)
13
+ value: enrichmentResponse
16
14
  });
17
15
  }
18
16
  }
@@ -21,18 +19,29 @@ export const toEnrichments = async ({ generators, oasDocument }) => {
21
19
  for (const [refName, schema] of Object.entries(oasDocument.components?.schemas ?? {})) {
22
20
  const enrichmentRequest = generator.toEnrichmentRequest?.(refName);
23
21
  if (enrichmentRequest) {
24
- const enrichmentResponse = await handleEnrichment(enrichmentRequest);
25
- if (!output[generator.id]) {
26
- output[generator.id] = [];
27
- }
28
- output[generator.id].push({
22
+ const enrichmentResponse = handleEnrichment(enrichmentRequest);
23
+ responses.push({
24
+ generatorId: generator.id,
29
25
  key: ['models', refName, 'enrichments'],
30
- value: JSON.parse(enrichmentResponse)
26
+ value: enrichmentResponse
31
27
  });
32
28
  }
33
29
  }
34
30
  }
35
31
  }
36
- console.log('OUTPUT', output);
37
- return output;
32
+ const items = await Promise.all(responses.map(async (response) => {
33
+ return {
34
+ generatorId: response.generatorId,
35
+ key: response.key,
36
+ value: await response.value
37
+ };
38
+ }));
39
+ return items.reduce((acc, { generatorId, key, value }) => {
40
+ acc[generatorId] = acc[generatorId] || [];
41
+ acc[generatorId].push({
42
+ key,
43
+ value: JSON.parse(value)
44
+ });
45
+ return acc;
46
+ }, {});
38
47
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skmtc/core",
3
- "version": "0.0.507",
3
+ "version": "0.0.508",
4
4
  "main": "./script/mod.js",
5
5
  "module": "./esm/mod.js",
6
6
  "exports": {
@@ -1 +1 @@
1
- {"version":3,"file":"handleEnrichment.d.ts","sourceRoot":"","sources":["../../src/run/handleEnrichment.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAA;AAetE,eAAO,MAAM,gBAAgB,GAAU,cAAc,0DAIlD,iBAAiB,CAAC,cAAc,CAAC,oBAyCnC,CAAA;AAGD,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC5D,GAAG,EAAE,CAAC,EACN,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,CAAC,CAAC,CAyBZ"}
1
+ {"version":3,"file":"handleEnrichment.d.ts","sourceRoot":"","sources":["../../src/run/handleEnrichment.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAA;AAetE,eAAO,MAAM,gBAAgB,GAAU,cAAc,0DAIlD,iBAAiB,CAAC,cAAc,CAAC,oBAqCnC,CAAA;AAGD,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC5D,GAAG,EAAE,CAAC,EACN,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,CAAC,CAAC,CAyBZ"}
@@ -40,7 +40,6 @@ const handleEnrichment = async ({ prompt, content, responseSchema: zodResponseSc
40
40
  const responseSchema = (0, zod_to_json_schema_1.zodToJsonSchema)(zodResponseSchema, {
41
41
  target: 'openApi3'
42
42
  });
43
- console.log('RESPONSE SCHEMA', responseSchema);
44
43
  const chatSession = model.startChat({
45
44
  generationConfig: {
46
45
  temperature: 1,
@@ -70,7 +69,6 @@ const handleEnrichment = async ({ prompt, content, responseSchema: zodResponseSc
70
69
  ]
71
70
  });
72
71
  const result = await chatSession.sendMessage(`${prompt}\n\n${content}`);
73
- console.log('RESULT', result);
74
72
  return result.response.text();
75
73
  };
76
74
  exports.handleEnrichment = handleEnrichment;
@@ -1 +1 @@
1
- {"version":3,"file":"toEnrichments.d.ts","sourceRoot":"","sources":["../../src/run/toEnrichments.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;AAC9D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AAI9D,KAAK,iBAAiB,CAAC,cAAc,IAAI;IACvC,UAAU,EAAE,aAAa,CAAC,cAAc,CAAC,EAAE,CAAA;IAC3C,WAAW,EAAE,WAAW,CAAA;CACzB,CAAA;AAED,MAAM,MAAM,cAAc,GAAG;IAC3B,GAAG,EAAE,MAAM,EAAE,CAAA;IACb,KAAK,EAAE,OAAO,CAAA;CACf,CAAA;AAED,eAAO,MAAM,aAAa,GAAU,cAAc,+BAG/C,iBAAiB,CAAC,cAAc,CAAC,8CA4CnC,CAAA"}
1
+ {"version":3,"file":"toEnrichments.d.ts","sourceRoot":"","sources":["../../src/run/toEnrichments.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;AAC9D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AAI9D,KAAK,iBAAiB,CAAC,cAAc,IAAI;IACvC,UAAU,EAAE,aAAa,CAAC,cAAc,CAAC,EAAE,CAAA;IAC3C,WAAW,EAAE,WAAW,CAAA;CACzB,CAAA;AAED,MAAM,MAAM,cAAc,GAAG;IAC3B,GAAG,EAAE,MAAM,EAAE,CAAA;IACb,KAAK,EAAE,OAAO,CAAA;CACf,CAAA;AAQD,eAAO,MAAM,aAAa,GAAU,cAAc,+BAG/C,iBAAiB,CAAC,cAAc,CAAC,8CA0DnC,CAAA"}
@@ -3,19 +3,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.toEnrichments = void 0;
4
4
  const handleEnrichment_js_1 = require("./handleEnrichment.js");
5
5
  const toEnrichments = async ({ generators, oasDocument }) => {
6
- const output = {};
6
+ const responses = [];
7
7
  for (const generator of generators) {
8
8
  if (generator.type === 'operation') {
9
9
  for (const operation of oasDocument.operations) {
10
10
  const enrichmentRequest = generator.toEnrichmentRequest?.(operation);
11
11
  if (enrichmentRequest) {
12
- const enrichmentResponse = await (0, handleEnrichment_js_1.handleEnrichment)(enrichmentRequest);
13
- if (!output[generator.id]) {
14
- output[generator.id] = [];
15
- }
16
- output[generator.id].push({
12
+ const enrichmentResponse = (0, handleEnrichment_js_1.handleEnrichment)(enrichmentRequest);
13
+ responses.push({
14
+ generatorId: generator.id,
17
15
  key: ['operations', operation.path, operation.method, 'enrichments'],
18
- value: JSON.parse(enrichmentResponse)
16
+ value: enrichmentResponse
19
17
  });
20
18
  }
21
19
  }
@@ -24,19 +22,30 @@ const toEnrichments = async ({ generators, oasDocument }) => {
24
22
  for (const [refName, schema] of Object.entries(oasDocument.components?.schemas ?? {})) {
25
23
  const enrichmentRequest = generator.toEnrichmentRequest?.(refName);
26
24
  if (enrichmentRequest) {
27
- const enrichmentResponse = await (0, handleEnrichment_js_1.handleEnrichment)(enrichmentRequest);
28
- if (!output[generator.id]) {
29
- output[generator.id] = [];
30
- }
31
- output[generator.id].push({
25
+ const enrichmentResponse = (0, handleEnrichment_js_1.handleEnrichment)(enrichmentRequest);
26
+ responses.push({
27
+ generatorId: generator.id,
32
28
  key: ['models', refName, 'enrichments'],
33
- value: JSON.parse(enrichmentResponse)
29
+ value: enrichmentResponse
34
30
  });
35
31
  }
36
32
  }
37
33
  }
38
34
  }
39
- console.log('OUTPUT', output);
40
- return output;
35
+ const items = await Promise.all(responses.map(async (response) => {
36
+ return {
37
+ generatorId: response.generatorId,
38
+ key: response.key,
39
+ value: await response.value
40
+ };
41
+ }));
42
+ return items.reduce((acc, { generatorId, key, value }) => {
43
+ acc[generatorId] = acc[generatorId] || [];
44
+ acc[generatorId].push({
45
+ key,
46
+ value: JSON.parse(value)
47
+ });
48
+ return acc;
49
+ }, {});
41
50
  };
42
51
  exports.toEnrichments = toEnrichments;